Avoid passing a nullable value to Completer<nn-type>.complete
This is cleanup work required to start enforcing this with static
analysis, as per dart-lang/sdk#53253.
Real quick this issue is that this code is unsafe:
```dart
void f(Completer<int> c, int? i) {
Future<int>.value(i); // Ouch!
c.complete(i); // Ouch!
}
```
Change-Id: I12c4f0a92a2071fb47759d9626689e00cfa42f8d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/324763
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analysis_server/test/stress/utilities/server.dart b/pkg/analysis_server/test/stress/utilities/server.dart
index 21c391a..157aabf 100644
--- a/pkg/analysis_server/test/stress/utilities/server.dart
+++ b/pkg/analysis_server/test/stress/utilities/server.dart
@@ -75,8 +75,9 @@
/// Return a future that will complete when a response is received.
Future<Response> get respondedTo {
- if (_response != null) {
- return Future.value(_response);
+ final response = _response;
+ if (response != null) {
+ return Future.value(response);
}
var completer = _responseCompleter ??= Completer<Response>();
return completer.future;