Files
kotlin-fork/compiler/testData/codegen/boxAgainstJava/notNullAssertions/rightElvisOperand.kt
T
Mark Punzalan 69cd729506 [FIR] Enable BlackBoxAgainstJavaCodegen tests for FIR.
23 out of 156 tests (14.7%) are currently failing.
2020-09-29 10:21:21 +03:00

33 lines
640 B
Kotlin
Vendored

// IGNORE_BACKEND_FIR: JVM_IR
// FILE: RightElvisOperand.java
class RightElvisOperand {
static String foo() {
return null;
}
}
// FILE: 1.kt
fun baz(): String? = null
fun bar(): String = baz() ?: RightElvisOperand.foo()
fun foo(x: String) {}
fun box(): String {
try {
foo(baz() ?: RightElvisOperand.foo())
return "Fail: should have been an exception in `foo(baz() ?: RightElvisOperand.foo())`"
}
catch(e: NullPointerException) {}
try {
bar()
return "Fail: should have been an exception in `bar()`"
}
catch(e: NullPointerException) {
return "OK"
}
}