Files
kotlin-fork/compiler/testData/codegen/box/nullCheckOptimization/javaNullCheckThrowsNpe.kt
T
2020-10-22 10:51:20 +03:00

22 lines
463 B
Kotlin
Vendored

// 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"
}
}