Skip to content

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

@Hixie

Description

@Hixie

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work oncustomer-flutterlegacy-area-analyzerUse area-devexp instead.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions