Files
kotlin-fork/compiler/testData/codegen/boxInline/contracts/propertyInitialization.kt
T
pyos a4b005fd5d PSI2IR: generate field writes for all val property assignments
Assuming the frontend is correct, and it hopefully is, all of them are
initializations even if not done in the owner class directly.
2019-12-20 13:03:39 +03:00

33 lines
457 B
Kotlin
Vendored

// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// IGNORE_BACKEND: NATIVE
// 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.*
class A {
val z: String
init {
myrun {
z = "OK"
}
}
}
fun box(): String {
return A().z
}