Ignore unnecessary casts that can go away soon.#64200
Merged
fluttergithubbot merged 1 commit intoflutter:masterfrom Aug 20, 2020
Merged
Ignore unnecessary casts that can go away soon.#64200fluttergithubbot merged 1 commit intoflutter:masterfrom
fluttergithubbot merged 1 commit intoflutter:masterfrom
Conversation
The number promotion rules in null safety mode have been changed to allow certain obvious operations to produce correct types (e.g. `double + double` now produces `double`; previously it produced `num`, so it required a cast to convert it to `double`). Flutter contains some casts to work around the drawbacks of the old rules; once the new rules are implemented in the analyzer, those casts will become unnecessary. To cover the transition period, ignore the unnecessary_cast hints now. After the new rules have landed, we will be able to remove the casts (and the "ignore" comments) completely.
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
Contributor
Author
Yup, documentation is here: https://github.com/dart-lang/language/blob/master/accepted/future-releases/nnbd/number-operation-typing.md |
Contributor
|
Ah I see, it's hard-coded magic for the |
smadey
pushed a commit
to smadey/flutter
that referenced
this pull request
Aug 27, 2020
mingwandroid
pushed a commit
to mingwandroid/flutter
that referenced
this pull request
Sep 6, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The number promotion rules in null safety mode have been changed to
allow certain obvious operations to produce correct types
(e.g.
double + doublenow producesdouble; previously it producednum, so it required a cast to convert it todouble). Fluttercontains some casts to work around the drawbacks of the old rules;
once the new rules are implemented in the analyzer, those casts will
become unnecessary. To cover the transition period, ignore the
unnecessary_cast hints now. After the new rules have landed, we will
be able to remove the casts (and the "ignore" comments) completely.
Related Issues
dart-lang/sdk#42629 (this PR must be landed before the issue can be fixed).
Tests
I added the following tests:
No tests. These changes will be tested when the fix for dart-lang/sdk#42629 rolls into Flutter.
Checklist
Before you create this PR, confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.