63b13027df
Except all, it's also useful to use one class of language version settings for compiler tests to configure it specially for tests
26 lines
536 B
Kotlin
Vendored
26 lines
536 B
Kotlin
Vendored
// !LANGUAGE: +CallsInPlaceEffect
|
|
|
|
import kotlin.internal.contracts.*
|
|
|
|
inline fun myRun(block: () -> Unit) {
|
|
contract {
|
|
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
|
|
}
|
|
block()
|
|
}
|
|
|
|
inline fun <T> unknownRun(block: () -> T): T = block()
|
|
|
|
fun throwIfNotCalled() {
|
|
val x: Int
|
|
myRun outer@ {
|
|
unknownRun {
|
|
myRun {
|
|
x = 42
|
|
return@outer
|
|
}
|
|
}
|
|
throw java.lang.IllegalArgumentException()
|
|
}
|
|
println(<!UNINITIALIZED_VARIABLE!>x<!>)
|
|
} |