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

Issues blocking Flutter's use of "implicit-casts: false". #30402

Closed
Hixie opened this issue Aug 10, 2017 · 4 comments
Closed

Issues blocking Flutter's use of "implicit-casts: false". #30402

Hixie opened this issue Aug 10, 2017 · 4 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. customer-flutter P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@Hixie
Copy link
Contributor

Hixie commented Aug 10, 2017

We get 1668 errors when using implicit-casts: false today.

I looked at some of them and found the following broad issues:

  1. We often have variables of type dynamic, which we then pass to methods that expect particular types. I think we want this to do a type check at runtime then cast automatically. The point of dynamic is that it opts you out of static typing.

  2. We have methods that take type arguments, do a search of a tree or Map or whatnot, then return an instance of the given type. The call sites assume the type is correct. Today, they take their type as a regular argument, and the return type is therefore not as tight as it could be. We would switch to generic type arguments to pass the type (allowing us to set the return type correctly), but the VM doesn't reify the types and we therefore couldn't actually do the search.

  3. 701 of the errors go away if we set declaration-casts: false. These are places where, once we have strong mode in the VM, we will be using as instead of assignments.

  4. double x = 0.0.clamp(0.0, 0.0); doesn't work because double returns num.

  5. Stream.firstWhere returns a Future<dynamic> instead of a Future<T>.

  6. There's probably others. With 1668 errors to go through, I could only sample the problems, and 1, 2, and 3 above are very common indeed so they swamp out the others.

@anders-sandholm anders-sandholm added analyzer-strong-mode area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Aug 11, 2017
@matanlurey
Copy link
Contributor

matanlurey commented Aug 13, 2017

We (AngularDart) have been talking internally about altering the default set of checks for "stricter" strong-mode with @leafpetersen and @jmesserly - maybe we can collaborate on this instead of having separate requests to the strong-mode team.

@bwilkerson bwilkerson added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug labels Aug 14, 2017
@bwilkerson
Copy link
Member

There is also issue #30397. It seems to me that the issue tracker is a good place to collaborate.

@srawlins
Copy link
Member

We often have variables of type dynamic, which we then pass to methods that expect particular types. I think we want this to do a type check at runtime then cast automatically. The point of dynamic is that it opts you out of static typing.

With the release of null safety, I think you have exactly what you want, and implicit-casts: false (and the upcoming strict-casts: true) are unnecessary for Flutter:

  • no implicit casts from a non-dynamic type to any other type are allowed.
  • the only checks that implicit-casts: false add are during an implicit cast from dynamic.

I can close if this analysis mode is not interesting for the Flutter team.

@srawlins
Copy link
Member

implicit-casts has landed. I recommend reviewing that flag and opening a new issue if it proves unhelpful in any way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. customer-flutter P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants