Files
kotlin-fork/compiler/testData/codegen/box/javaInterop/notNullAssertions/destructuringAssignmentWithNullabilityAssertionOnExtensionReceiver_lv12.kt
T
Ivan Kylchik c7435ba760 Replace all occurrences of WITH_RUNTIME with WITH_STDLIB
We are going to deprecate `WITH_RUNTIME` directive. The main reason
behind this change is that `WITH_STDLIB` directive better describes
its meaning, specifically it will add kotlin stdlib to test's classpath.
2021-11-17 15:26:38 +03:00

29 lines
609 B
Kotlin
Vendored

// TARGET_BACKEND: JVM
// WITH_STDLIB
// FILE: destructuringAssignmentWithNullabilityAssertionOnExtensionReceiver_lv12.kt
import kotlin.test.*
var component1Evaluated = false
// NB extension receiver is nullable
operator fun J?.component1() = 1.also { component1Evaluated = true }
private operator fun J.component2() = 2
fun use(x: Any) {}
fun box(): String {
assertFailsWith<NullPointerException> {
val (a, b) = J.j()
}
if (!component1Evaluated) return "component1 should be evaluated"
return "OK"
}
// FILE: J.java
public class J {
public static J j() { return null; }
}