You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Mixin declarations currently may not declare factory constructors:
mixinM {
// This is an errorfactoryM.foo() =>throw"hello";
}
Both variants of the static extensions proposal in this PR imply that static extensions can be used to add factory constructors to mixin declarations (am I missing a restriction or error somewhere?). That is, the following would be legal:
Is this intentional? It seems slightly unfortunate that using an extension becomes "the way" to get a constructor onto a mixin. Should we relax this restriction on mixin declarations?
cc @dart-lang/language-team
The text was updated successfully, but these errors were encountered:
There is little practical difference between static M foo() => throw 'hello'; and factory M.foo() => throw 'hello';. Do we plan to allow a static extension to define the unnamed constructor? That's one affordance that might still only be open if we allow mixins to define factory constructors.
I don't see any harm in relaxing the existing restriction.
Mixin declarations currently may not declare factory constructors
That's a long-standing missing feature. There was never any reason to disallow factory constructors on mixin declarations, and it should just be allowed.
We discussed that with class modifiers too, but to late in the process to want to add more to the feature.
Mixin declarations currently may not declare factory constructors:
Both variants of the static extensions proposal in this PR imply that static extensions can be used to add factory constructors to mixin declarations (am I missing a restriction or error somewhere?). That is, the following would be legal:
Is this intentional? It seems slightly unfortunate that using an extension becomes "the way" to get a constructor onto a mixin. Should we relax this restriction on mixin declarations?
cc @dart-lang/language-team
The text was updated successfully, but these errors were encountered: