-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
To-non-nullable indicator for type parameters like T!
#4160
Comments
I recommend doing: class Foo<T extends Object> {
T foo() => ...
// use T? everywhere being nullable is allowed.
} Even if we had a The |
That's not an accurate representation. |
It's not the same, and nothing is because the functionality your asking for doesn't exist. I often find that the rewrite gives a better design, because the type Looking at it again, if the construct is going to work, the Normalization would convert Subtyping would treat The interface signature of It introduces yet another special-cased type, like the union types |
We can currently have a type parameter like
class Foo<T extends Object> {}
and specify a method to returnT?
: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 ofT
, I propose we add aT!
variation so we can have: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
.The text was updated successfully, but these errors were encountered: