Files
kotlin-fork/compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/capturedVariable.kt
T
2024-01-10 11:10:08 +00:00

24 lines
491 B
Kotlin
Vendored

// !LANGUAGE: +NoSourceCodeInNotNullAssertionExceptions
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM
// FILE: test.kt
fun f(x: String) = "Fail 1"
fun box(): String {
return try {
val variable = J().s()
val block = { f(variable) }
block()
} catch (e: NullPointerException) {
if (e.message == null)
"OK"
else
"Fail: ${e.message}"
}
}
// FILE: J.java
public class J {
public final String s() { return null; }
}