Skip to content

Strong mode analyzer inconsistent about when types must match #30385

@Hixie

Description

@Hixie

Consider this code:

class A { }
class B extends A { }

void test<T>(T v) { }

void main() {
  final A x = new A();
  test<B>(x); // no error

  test<B>(new A()); // strong_mode_invalid_cast_new_expr
}

Why are these different?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onclosed-duplicateClosed in favor of an existing reportlegacy-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