Skip to content

breaking change: remove support for old super-mixins from CFE and VM #48167

@mraleph

Description

@mraleph

Background

Currently CFE allows certain targets (e.g. Flutter, Dart CLI) to use old super mixin feature - which permitted to classes to be used as mixins even when they extended something that was not an Object.

Meaning that CFE would compile (and VM would run) the following code:

class Base {}

class Mixin extends Base {
}

class C extends Base with Mixin {
}

Analyzer rejects this code with mixin_inherits_from_not_object error:

  error • test.dart:5:27 • The class 'Mixin' can't be used as a mixin because it extends a class other than 'Object'. • mixin_inherits_from_not_object

Though this error can be suppressed via // ignore:mixin_inherits_from_not_object.

The analyser used to support this feature (hidden under a flag) but this support has been removed.

Proposed change

We propose to remove support for this feature from CFE.

Migration

Users should migrate their class Mixin extends Base declarations to use mixin Mixin on Base declarations instead.

class Base {}

mixin Mixin on Base {
}

class C extends Base with Mixin {
}

Impact

Given that the analyzer issues an error by default we consider the risk to be minimal.

As far as we can neither Flutter no internally Google code base does not contain any suppressions for mixin_inherits_from_not_object which means it does not contain any uses of these feature.

Only users that explicitly suppressed analysis error will be affected and will be required to migrate.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions