8a01da6ec6
by generating a box for the value. #KT-26126 Fixed
21 lines
523 B
Kotlin
Vendored
21 lines
523 B
Kotlin
Vendored
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect +ReadDeserializedContracts
|
|
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
|
// IGNORE_BACKEND: JVM_IR, NATIVE, JS_IR
|
|
|
|
import kotlin.contracts.*
|
|
|
|
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
|
public fun myrun(block: () -> Unit) {
|
|
contract {
|
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
}
|
|
block()
|
|
}
|
|
|
|
fun box(): String {
|
|
val x: Long
|
|
myrun {
|
|
x = 1L
|
|
}
|
|
return if (x != 1L) "FAIL" else "OK"
|
|
} |