Skip to content

Allow mixins to be used with const constructors #18707

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
nex3 opened this issue May 8, 2014 · 1 comment
Closed

Allow mixins to be used with const constructors #18707

nex3 opened this issue May 8, 2014 · 1 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

Comments

@nex3
Copy link
Member

nex3 commented May 8, 2014

A mixin cannot explicitly declare any constructors. However, it does implicitly declare a constructor that is called by classes that include the mixin. Since this constructor is not const, this means that mixins can't ever be used by classes with const constructors.

One possible solution to this would be to have the implicit mixin constructor be const for mixins with no instance variables.

@lrhn
Copy link
Member

lrhn commented May 8, 2014

I assume you mean "mixin application" when you say "mixin", and is not referring to the class that is used as mixin (which does have an implicit default constructor).

The implicit "forwarding" constructors on a mixin application are indeed all non-const. You can't make them const if the superclass constructor that they forward to isn't also const, but in that case, I would also very much want that to be done when possible for all mixin application of classes with no non-final instance fields.


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

@nex3 nex3 added Type-Defect 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 May 8, 2014
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
Projects
None yet
Development

No branches or pull requests

3 participants