mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-17 08:31:29 +00:00
Add codegen tests for old behavior of null checks
#KT-22275
This commit is contained in:
22
compiler/testData/codegen/box/nullCheckOptimization/javaNullCheckThrowsNpe.kt
vendored
Normal file
22
compiler/testData/codegen/box/nullCheckOptimization/javaNullCheckThrowsNpe.kt
vendored
Normal 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"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user