Skip to content

Allow type parameters on constructors #34414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Hixie opened this issue Sep 10, 2018 · 2 comments
Closed

Allow type parameters on constructors #34414

Hixie opened this issue Sep 10, 2018 · 2 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug

Comments

@Hixie
Copy link
Contributor

Hixie commented Sep 10, 2018

I have a class of type Foo<T> which I want to construct using a source of R values and a callback that can convert Rs to Ts.

   typedef T Converter<R, T>(R value);
   class Foo<T> {
     factory Foo.convert<R>(Bar<R> source, Converter<R, T> converter) {
       // ...
     }
   }

This fails with Error: Constructors can't have type parameters.

@Hixie
Copy link
Contributor Author

Hixie commented Sep 10, 2018

(Using a static method instead fails with #34415.)

@eernstg eernstg added area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug labels Sep 10, 2018
@eernstg
Copy link
Member

eernstg commented Sep 10, 2018

This has been in the pipeline for a while, it just didn't make it into Dart 2. We have https://github.com/dart-lang/sdk/issues/26391 which is used to discuss (and push for) that feature, so I'll close this one as a duplicate thereof.

@eernstg eernstg closed this as completed Sep 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

2 participants