Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop passing a nullable value to Future<nn-type>.value or Completer<nn-type>.completer #6228

Merged
merged 2 commits into from
Aug 21, 2023

Conversation

srawlins
Copy link
Contributor

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:

void f(Completer<int> c, int? i) {
  Future<int>.value(i); // Ouch!
  c.complete(i);        // Ouch!
}

The typical fix is to add a null-assert (!), but sometimes a more appropriate or safer fix can be made.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read the Flutter Style Guide recently, and have followed its advice.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or there is a reason for not adding tests.

build.yaml badge

If you need help, consider asking for help on Discord.

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

The typical fix is to add a null-assert (`!`), but sometimes a more appropriate or safer fix can be made.
@srawlins srawlins requested a review from a team as a code owner August 21, 2023 17:11
@srawlins srawlins requested review from polina-c and removed request for a team August 21, 2023 17:11
Copy link
Member

@kenzieschmoll kenzieschmoll left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with one suggestion

@srawlins srawlins merged commit c2e0343 into master Aug 21, 2023
20 of 21 checks passed
@srawlins srawlins deleted the fix-future-value branch August 21, 2023 22:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants