Files
kotlin-fork/compiler/testData/codegen/boxInline/contracts/propertyInitialization.kt
T
2017-12-19 16:11:39 +01:00

30 lines
463 B
Kotlin
Vendored

// !LANGUAGE: +CallsInPlaceEffect
// 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.*
class A {
val z: String
init {
myrun {
z = "OK"
}
}
}
fun box(): String {
return A().z
}