dart-lang / dart-lang/language
Make `extends C implements C` and `extends C with C` a warning
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
[Update Feb 2026: This is now about `extends C with C`, the other case is handled in #4642.]
[Cf. the discussion in https://github.com/dart-lang/sdk/issues/42256].
It is currently an error to have the same type as a superclass and also as one of the types in the `implements` clause:
```dart
class A {}
class B extends A implements A {} // Compile-time error.
```
This error is solely motivated by the fact that this is a confusing construct that provides no affordances at all (hence also: no useful affordances).
This issue is a proposal that we should change that from being a compile-time error to being a non-error. At this time, the language specification documents do not have an opinion about warnings (except for a few, for historical reasons), but the language team could recommend that it is somehow reported, e.g., as a warning from the analyzer, or as a lint.
This would make the mixin application `C with C` a warning/lint when `C` is a mixin class (because the specified meaning of that mixin application is a class where `C` is the superclass as well as an element in the `implements` list).
We could also have a lint for the case where the same mixin or mixin class occurs two or more times in a `with` clause (like `class D = Object with M, M;`). This would be consistent with the warning for `C with C` mentioned above, and it makes sense from a software engineering perspective because repeated occurrences of a mixin is a construct which is very unlikely to be useful (and very likely to be a mistake).
Anyone who _really_ needs repeated occurrences of the same mixin in the same class would just need to ignore that lint.
@dart-lang/language-team, WDYT?
Contributor guide
Research direction
Start with the updated scope: `extends C with C` when `C` is a mixin class; the issue does not name an implementation file or test. Read the linked discussion in #42256 and the language specification material, then determine whether the intended result is an analyzer warning or lint and whether repeated mixins should also be covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100