-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Factory methods should have direct access to type parameters #22700
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
Comments
This comment was originally written by @mezoni But the "factory" are syntactic sugar over the static methods. Even if they in Dart available with an operator "new" this does not means that they are constructors. This is also syntactic sugar over the static methods. |
This comment was originally written by [email protected] Thanks for the comment. As you see above, factory methods have access to the generic type parameters. The first factory constructor actually works. It's just that wrapper code is needed to get around the unnecessary error. |
Removed Type-Defect label. |
I think this is a bug in the VM. The spec says This says that the body is executed in a scope where the type parameter is in scope. Removed Type-Enhancement, Area-Language labels. |
Fixed at r44339. Corresponding issues have been opened for dart2js (22738) and analyzer (22739). Added Fixed label. |
This issue was originally filed by [email protected]
Right now, I get: cannot access type parameter 'T' from static function
As the example above shows T is available using wrapper code. So the error should not have to occur for factory methods.
Thanks,
Andreas
The text was updated successfully, but these errors were encountered: