-
Notifications
You must be signed in to change notification settings - Fork 289
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
Support definitely non-nullable types #1268
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think modeling this as an intersection type rather than some specialization of a type variable is a better and more future-proof path.
val typeName = TypeVariableName("T").copy() | ||
assertThat(typeName.toString()).isEqualTo("T & Any") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very surprising behavior
That sounds reasonable to me. API like this maybe? TypeVariableName(..., intersects = listOf(ANY)) The thing I'm less sure about though is how to indicate that this needs to be emitted. |
I was thinking more like |
Hmmm, is that a breaking change if TypeName is currently sealed to add another? |
It's source incompatible and will cause a runtime exception for |
What if we made |
I think that seems reasonable. In general for 2.0, I think we should take a closer look at how kotlinc models these and consider mirroring it, including making |
From https://kotlinlang.org/docs/whatsnew17.html#stable-definitely-non-nullable-types
Open to suggestions on the API for this, went back and forth on an explicit
asDefinitelyNonNullable()
orcopy(isDefinitelyNonNullable: Boolean)
overload. Also open to suggestions on whether or not any of the checks are cases we should silently "fix" for them, like settingisDefinitelyNonNullable
to false if copying over asnullable
.