Skip to content
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

Make mixins forward const constructors. #9745

Closed
lrhn opened this issue Apr 8, 2013 · 6 comments
Closed

Make mixins forward const constructors. #9745

lrhn opened this issue Apr 8, 2013 · 6 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@lrhn
Copy link
Member

lrhn commented Apr 8, 2013

Currently mixin application is specified as creating forwarding constructors for all generative constructors of the superclass.
The created constructors are not const constructors, making it impossible to create a const class with a mixin.

If the superclass constructor is a const constructor, and the mixin doesn't add any fields, please make the created constructor also a const constructor. That would make it possible to create a const class using a mixin:

  class EmptyList<E> extends Object with ImmutableListMixin<E> {
    int get length => 0;
    int operator[](int i) { throw new RangeError.value(i); }
  }

  ... return const EmptyList(); ...

Not having const constructors makes mixins less useful.

@gbracha
Copy link
Contributor

gbracha commented Aug 21, 2013

The restrictions on mixins should be relaxed, but not by adding more special rules. We've had this discussion and concluded that the spec will remain as it is until full constructor support is allowed in mixins.


Set owner to @gbracha.
Added this to the Later milestone.
Added Accepted label.

@lrhn
Copy link
Member Author

lrhn commented May 8, 2014

Issue #18707 has been merged into this issue.

@kasperl
Copy link

kasperl commented Jul 10, 2014

Removed this from the Later milestone.
Added Oldschool-Milestone-Later label.

@kasperl
Copy link

kasperl commented Aug 4, 2014

Removed Oldschool-Milestone-Later label.

@lrhn lrhn added Type-Defect area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Aug 4, 2014
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed accepted labels Feb 29, 2016
@eernstg
Copy link
Member

eernstg commented Apr 21, 2017

Issue #29396 was closed as a duplicate of this one; check out that issue for the example.

@eernstg
Copy link
Member

eernstg commented Feb 19, 2018

Closing: As of 63c6851, constructor forwarding does just that. Created #32223 to put this into the implementation pipeline.

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). P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants