Skip to content

Commit

Permalink
Avoid passing a nullable value to Future<nn-type>.value or Completer<…
Browse files Browse the repository at this point in the history
…nn-type>.completer.

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!
}
```

This change should be a no-op. Adding this explicit null-assert ensures that any exception is thrown right at the null-assert.
  • Loading branch information
srawlins committed Sep 6, 2023
1 parent 9487a45 commit 38d938f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dwds/lib/src/services/batched_expression_evaluator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class BatchedExpressionEvaluator extends ExpressionEvaluator {
length: requests.length,
)
.then((v) {
final result = v.first.value;
final result = v.first.value!;
_logger.fine(
'Got result out of a batch for ${request.expression}: $result',
);
Expand Down

0 comments on commit 38d938f

Please sign in to comment.