Allow optional arguments in synthetic constructors for mixins #17610
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
The rules for synthetic constructors from superclasses in mixins do not cover optional arguments, implying that constructors with optional arguments are not available to call as super-constructors from the class that extends the mixin application:
Section 9.1:
For each generative constructor named
q_i(T_i1 a_i1; ... ; T_iki a_iki)
C has an implicitly declared constructor named
q_0i(a_i1; ... ; aiki) : super(a_i1; ... ; a_iki);
Is this on purpose?
It means that the following example does not work:
class A {
A([this.o]);
}
class M {}
class B extends A with M {
B([o]) : super(o);
}
main() => new B(1);
and it actually fails in the VM with the error message:
forwarding constructors must not have optional parameters
class B extends A with M {
^
The text was updated successfully, but these errors were encountered: