Issues blocking Flutter's use of "implicit-casts: false". #30402
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
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: