Mixin class can only extend `Object`DRT-W1487
The analyzer produces this diagnostic when a class that is marked with
the mixin
modifier extends a class other than Object
. A mixin class
can't have a superclass other than Object
.
Example
The following code produces this diagnostic because the class B
, which
has the modifier mixin
, extends A
:
class A {}
mixin class B extends A {}
Common fixes
If you want the class to be used as a mixin, then change the superclass to
Object
, either explicitly or by removing the extends clause:
class A {}
mixin class B {}
If the class needs to have a superclass other than Object
, then remove
the mixin
modifier:
class A {}
class B extends A {}
If you need both a mixin and a subclass of a class other than Object
,
then move the members of the subclass to a new mixin, remove the mixin
modifier from the subclass, and apply the new mixin to the subclass:
class A {}
class B extends A with M {}
mixin M {}
Depending on the members of the subclass this might require adding an on
clause to the mixin.