Add codegen tests for old behavior of null checks

#KT-22275
This commit is contained in:
Alexander Udalov
2020-01-22 15:58:49 +01:00
parent 632fe18db6
commit 2fca7f1a54
15 changed files with 160 additions and 127 deletions

View File

@@ -0,0 +1,22 @@
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// FILE: A.java
import org.jetbrains.annotations.NotNull;
public class A {
@NotNull
public static String foo() { return null; }
}
// FILE: test.kt
fun box(): String {
try {
val s: String = A.foo()
return "Fail: NPE should have been thrown"
} catch (e: Throwable) {
if (e::class != NullPointerException::class) return "Fail: exception class should be NPE: ${e::class}"
return "OK"
}
}