Files
kotlin/compiler/testData/codegen/boxAgainstJava/notNullAssertions/rightElvisOperand.kt
2016-03-02 15:47:36 +03:00

32 lines
612 B
Kotlin
Vendored

// 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: IllegalStateException) {}
try {
bar()
return "Fail: should have been an exception in `bar()`"
}
catch(e: IllegalStateException) {
return "OK"
}
}