Skip to content

Redirecting factory constructors don't propagate generic type arguments #30855

Closed
@leafpetersen

Description

@leafpetersen

This code:

class B<T> {
  B(a) : this.named(a);
  B.named(a) {}
  factory B.redirect(a) = B;
}

produces this error in current strong mode analyzer:

  error • The return type 'B<dynamic>' of the redirected constructor isn't assignable to 'B<T>' at /Users/leafp/tmp/test.dart:5:27 • redirect_to_invalid_return_type

I believe that redirecting factory constructors should propagate their type arguments unchanged.

cc @bkonyi @jmesserly @lrhn @eernstg @floitschG @munificent @stereotype441

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions