dart-lang / dart-lang/language
To-non-nullable indicator for type parameters like `T!`
- Dominant language
- TeX
- Stars
- 2.9k
- Forks
- 239
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 14
Description
We can currently have a type parameter like `class Foo {}` and specify a method to return `T?`:
```dart
class Foo {
T? foo() => null;
}
```
However we can't do this in the other way, meaning we have a `T extends Object?` and we want to specify a method to return a non-nullable version of `T`, I propose we add a `T!` variation so we can have:
```dart
class Foo {
T! foo() => ...;
}
```
This is useful in the context of Java interop where the type parameter itself can be nullable but a single method be annotated with `@NonNull`.
Contributor guide
Research direction
Start by reviewing the proposal's examples for nullable and non-nullable type parameters, then trace the Dart language specification areas covering type parameters, nullability, and Java interop. Done means reaching an accepted language-design decision and documenting the semantics of the proposed T! syntax.
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