Fix mapping of nullable generic underlying types of inline classes

#KT-32162 Fixed
This commit is contained in:
Ilmir Usmanov
2022-02-22 00:15:32 +01:00
committed by teamcity
parent 981f8b1871
commit 8811f62300
77 changed files with 3400 additions and 131 deletions
@@ -14,6 +14,10 @@ OPTIONAL_JVM_INLINE_ANNOTATION
value class WithNullableReference<T>(val a: T)
fun <T> takeWithNullableReference(a: WithNullableReference<T>) {}
OPTIONAL_JVM_INLINE_ANNOTATION
value class WithNullableReference2<T: Any>(val a: T?)
fun <T: Any> takeWithNullableReference2(a: WithNullableReference2<T>) {}
fun <T: Int> foo(a: WithPrimitive<T>?, b: WithPrimitive<T>) {
takeWithPrimitive(a!!) // unbox
takeWithPrimitive(a) // unbox
@@ -33,6 +37,13 @@ fun <T, R> baz(a: WithNullableReference<T>?, b: WithNullableReference<R>) {
takeWithNullableReference(b!!)
}
fun <T: Any, R: Any> baz2(a: WithNullableReference2<T>?, b: WithNullableReference2<R>) {
takeWithNullableReference2(a!!) // unbox
takeWithNullableReference2(a) // unbox
takeWithNullableReference2(a!!) // unbox
takeWithNullableReference2(b!!)
}
fun box(): String {
val a1 = WithPrimitive(1)
val b1 = WithPrimitive(2)
@@ -48,5 +59,10 @@ fun box(): String {
baz(a3, a4)
val a32 = WithNullableReference2("test")
val a42 = WithNullableReference2(123)
baz2(a32, a42)
return "OK"
}