-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Comments
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. |
There is also issue #30397. It seems to me that the issue tracker is a good place to collaborate. |
With the release of null safety, I think you have exactly what you want, and
I can close if this analysis mode is not interesting for the Flutter team. |
|
We get 1668 errors when using
implicit-casts: false
today.I looked at some of them and found the following broad issues:
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 ofdynamic
is that it opts you out of static typing.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.
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 usingas
instead of assignments.double x = 0.0.clamp(0.0, 0.0);
doesn't work becausedouble
returnsnum
.Stream.firstWhere
returns aFuture<dynamic>
instead of aFuture<T>
.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.
The text was updated successfully, but these errors were encountered: