Skip to content

Ignore unnecessary casts that can go away soon.#64200

Merged
fluttergithubbot merged 1 commit intoflutter:masterfrom
stereotype441:b-42629-8
Aug 20, 2020
Merged

Ignore unnecessary casts that can go away soon.#64200
fluttergithubbot merged 1 commit intoflutter:masterfrom
stereotype441:b-42629-8

Conversation

@stereotype441
Copy link
Contributor

Description

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.

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.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Did any tests fail when you ran them? Please read Handling breaking changes.

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.
@stereotype441 stereotype441 requested a review from Hixie August 19, 2020 23:44
@flutter-dashboard
Copy link

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.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Aug 19, 2020
Copy link
Contributor

@Hixie Hixie left a comment

Choose a reason for hiding this comment

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

Oooh, nice. How does that work? Is it documented anywhere?

LGTM

@stereotype441
Copy link
Contributor Author

@Hixie

Oooh, nice. How does that work? Is it documented anywhere?

Yup, documentation is here: https://github.com/dart-lang/language/blob/master/accepted/future-releases/nnbd/number-operation-typing.md

@Hixie
Copy link
Contributor

Hixie commented Aug 20, 2020

Ah I see, it's hard-coded magic for the num hierarchy. Pity, I was hoping it was something we could reuse. :-) Not that I had any particular use case in mind, but you know...

@fluttergithubbot fluttergithubbot merged commit 32464aa into flutter:master Aug 20, 2020
@stereotype441 stereotype441 deleted the b-42629-8 branch August 20, 2020 09:51
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
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants