Skip to content

Allow optional arguments in synthetic constructors for mixins #17610

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
karlklose opened this issue Mar 19, 2014 · 3 comments
Closed

Allow optional arguments in synthetic constructors for mixins #17610

karlklose opened this issue Mar 19, 2014 · 3 comments
Assignees
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

@karlklose
Copy link
Contributor

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 {
                         ^

@gbracha
Copy link
Contributor

gbracha commented Mar 19, 2014

Really all the restrictions on mixins need to go away. They are all driven by short term implementation considerations. I doubt if we will change this before the first ECMA standard is approved, but we'll see.


Set owner to @gbracha.
Added Accepted label.

@crelier
Copy link
Contributor

crelier commented Jun 5, 2014

See also issues 1501 and 19226.
Improved error message suggesting workaround submitted as r37057.

@gbracha
Copy link
Contributor

gbracha commented Aug 26, 2014

Added Duplicate label.
Marked as being merged into #15101.

@karlklose karlklose added Type-Enhancement 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 labels Aug 26, 2014
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed priority-unassigned labels Mar 1, 2016
This issue was closed.
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

4 participants