FIR: Use intersection of all upper bounds for parameterized types in
ConeKotlinType.canBeNull. ^KT-45903 In progress
This commit is contained in:
committed by
TeamCityServer
parent
ac85f9d983
commit
21a3a14289
+26
@@ -0,0 +1,26 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM, JVM_IR
|
||||
|
||||
// Note: This fails on non-FIR because of KT-45903 (missing not-null assertion on argument).
|
||||
|
||||
// FILE: typeParameterWithMixedNullableAndNotNullableBounds.kt
|
||||
fun <T> f(x: T): Int where T : CharSequence?, T : Comparable<T> {
|
||||
try {
|
||||
return x.compareTo(x)
|
||||
} catch (e: NullPointerException) {
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = try {
|
||||
val r = f(J.s())
|
||||
if (r == 42) "FAIL" else "Unexpected, x.compareTo(x) should have NPE'd"
|
||||
} catch (e: NullPointerException) {
|
||||
"OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static String s() { return null; }
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: typeParameterWithMultipleNotNullableBounds.kt
|
||||
fun <T> f(x: T): Int where T : CharSequence, T : Comparable<T> {
|
||||
try {
|
||||
return x.compareTo(x)
|
||||
} catch (e: NullPointerException) {
|
||||
return 42
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = try {
|
||||
val r = f(J.s())
|
||||
if (r == 42) "FAIL" else "Unexpected, x.compareTo(x) should have NPE'd"
|
||||
} catch (e: NullPointerException) {
|
||||
"OK"
|
||||
}
|
||||
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static String s() { return null; }
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: typeParameterWithMultipleNullableBounds.kt
|
||||
fun <T> f(x: T): Int? where T : CharSequence?, T : Comparable<T>? {
|
||||
return x?.compareTo(x)
|
||||
}
|
||||
|
||||
fun box() = f(J.s()) ?: "OK"
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static String s() { return null; }
|
||||
}
|
||||
Reference in New Issue
Block a user