Skip to content

Constant forwarding constructors could be supported #27061

Closed
@johnniwinther

Description

@johnniwinther

Currently constant forwarding constructors are not supported, which seems like an oversight.

For instance:

class S {
  final a, b;
  const S({this.a, this.b});
}
class M {}
class C extends S with M {
  const C() : super(b: 2, a: 1);
}
main() => const C();

const C() is not allowed since the super constructor (S+M) is not constant. This could be supported if the constness of the S constructor propagated to the forwarding S+M constructor where feasible.

Metadata

Metadata

Assignees

Labels

area-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).closed-duplicateClosed in favor of an existing reporttype-enhancementA request for a change that isn't a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions