dart-lang / dart-lang/language
Unable to specify interfaces or mixins as type arguments
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
```dart
// Let A be a class
class A {}
// Let X be a method taking a type argument
void X(){}
// Calling X with A as a type argument works, as intended.
final v = X();
// Change X to take a Type argument that extends A
void X(){}
// Again, this works, as A is A
final v = X();
// Now, Let B be a mixin
mixin B {}
// Let class C extend A and mixin B
class C extends A with B {} //EDIT: forgot "extends A"
// Change X to take a Type argument that extends A, and mixes in B
// This does not work as it is not valid syntax
void X(){}
// Change X to take a Type argument that extends A, and implements B
// This is not valid either
void X(){}
// For now, the only solutions are creating a class that pre-mixes a mixin
class C extends A with B{}
void X(){}
// Or make the mixin specific to a class, and tell the function to take types that extend the mixin
// This does not allow for multiple mixins however
mixin B on A {}
class C with B{}
void X(){}
```
Contributor guide
Research direction
Start by reviewing the Dart examples in the issue, especially the invalid type-argument forms using `extends A with B` and `extends A implements B`. Done would mean the language design clearly supports expressing a type argument constrained by both a superclass and a mixin or interface, with valid syntax and specified behavior.
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
- 25/100