Skip to content

call-through getter that retuns a generic class causes a confusing error message from CFE #32238

@mraleph

Description

@mraleph
class ActionDispatcher<P> {
  void call([P value]) { }
}

class Bar { }

class FooActions {
  ActionDispatcher<Bar> get foo =>
    new ActionDispatcher<Bar>();
}

void main() {
  // Error: A value of type '#lib1::Bar' can't be assigned to a variable of type '#lib1::ActionDispatcher::P'.
  // Try changing the type of the left hand side, or casting the right hand side to '#lib1::ActionDispatcher::P'.                           ^
  new FooActions().foo(new Bar());

  new FooActions().foo.call(new Bar());  // No error
  (new FooActions().foo)(new Bar());  // No error
}

might be related to @stereotype441's refactoring of callables.

Reduced from a case provided by @zoechi from his Flutter project hence marking Flutter.

Metadata

Metadata

Assignees

Labels

P0A serious issue requiring immediate resolutioncustomer-flutterlegacy-area-front-endLegacy: Use area-dart-model instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions