Illegal concrete member in EnumDRT-W1381
The analyzer produces this diagnostic when either an enum declaration, a
class that implements Enum
, or a mixin with a superclass constraint of
Enum
, declares or inherits a concrete instance member named either
index
, hashCode
, or ==
.
Examples
The following code produces this diagnostic because the enum E
declares
an instance getter named index
:
enum E {
v;
int get index => 0;
}
The following code produces this diagnostic because the class C
, which
implements Enum
, declares an instance field named hashCode
:
abstract class C implements Enum {
int hashCode = 0;
}
The following code produces this diagnostic because the class C
, which
indirectly implements Enum
through the class A
, declares an instance
getter named hashCode
:
abstract class A implements Enum {}
abstract class C implements A {
int get hashCode => 0;
}
The following code produces this diagnostic because the mixin M
, which
has Enum
in the on
clause, declares an explicit operator named ==
:
mixin M on Enum {
bool operator ==(Object? other) => false;
}
Common fixes
Rename the conflicting member:
enum E {
v;
int get getIndex => 0;
}