dart-lang / dart-lang/language
[Static extensions] Can static extensions add members to (or via) a typedef?
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
Extensions can be defined with typedef names as the on type:
```dart
class C {
}
typedef D = C;
extension E on D {
int get foo => 3;
}
void main() {
print(C().foo);
}
```
Should static extensions work when the on type is a typedef? If so, are they only accessible via the typedef name, or only via the name of the underlying class, or both?
```dart
class C {
}
typedef D = C;
// Error? Or allowed?
extension E on D {
static int bar() => 3;
}
void main() {
print(D.bar()); // Error or not?
print(C.bar()); // Error or not?
}
```
Contributor guide
Research direction
Start with the issue's typedef and static-extension examples, then review the language rules governing extension declarations and member lookup. Determine whether static members on an extension whose on type is a typedef are allowed and whether calls through D, C, or both should work. Done means the behavior is decided and specified consistently.
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