Sdk: Const constructor can't be declared for a class with a mixin that declares an instance field

Created on 7 Jun 2020  路  3Comments  路  Source: dart-lang/sdk

Is it a bug or a feature?

mixin A {
  int get prop => 1;
}

class B with A {
  const B();
}

_-> Const constructor can't be declared for a class with a mixin that declares an instance field_

But this works!

class A {
  const A();
  int get prop => 1;
}

class B extends A {
  const B();
}
area-analyzer type-bug

Most helpful comment

This is a bug, int get prop => 1; does not declare an instance field. In commit 578fa6bee9eb8917ed868bf4b6daafecfe2be491 the error is reported by the analyzer, but not by dart.

All 3 comments

This is a bug, int get prop => 1; does not declare an instance field. In commit 578fa6bee9eb8917ed868bf4b6daafecfe2be491 the error is reported by the analyzer, but not by dart.

Thanks for reporting this issue! This is a duplicate of https://github.com/dart-lang/sdk/issues/37810

Was this page helpful?
0 / 5 - 0 ratings