Files
kotlin-fork/compiler/testData/codegen/boxInline/contracts/complexInitializer.kt
T
2022-08-01 08:57:16 +00:00

30 lines
454 B
Kotlin
Vendored

// !OPT_IN: kotlin.contracts.ExperimentalContracts
// FILE: 1.kt
package test
import kotlin.contracts.*
public inline fun <R> myrun(block: () -> R): R {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return block()
}
// FILE: 2.kt
import test.*
fun cond() = true
fun test(s: String) = s
fun box(): String {
val x: String
myrun {
x = if (cond()) test("OK") else test("fail")
}
return x
}