Files
kotlin/compiler/testData/codegen/boxInline/contracts/complexInitializer.kt
2018-06-28 12:26:41 +02:00

29 lines
586 B
Kotlin
Vendored

// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect +ReadDeserializedContracts
// IGNORE_BACKEND: JVM_IR
// FILE: 1.kt
package test
import kotlin.internal.contracts.*
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
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
}