Files
kotlin-fork/compiler/testData/cfgVariablesWithStdLib/contracts/breakContinuesInInlinedLambda.kt
T
Mikhail Zarechenskiy 63b13027df Configure pseudocode tests with !LANGUAGE directive
Except all, it's also useful to use one class of language version settings for compiler tests to configure it specially for tests
2017-11-13 16:27:20 +03:00

43 lines
883 B
Kotlin
Vendored

// !LANGUAGE: +CallsInPlaceEffect
import kotlin.internal.contracts.*
inline fun <T> myRun(block: () -> T): T {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
}
return block()
}
fun getBoolean(): Boolean = false
fun test() {
val x: Int
if (getBoolean())
myRun {
while (getBoolean()) {
do {
myRun {
if (getBoolean()) {
x = 42
}
else {
x = 43
}
}
break
} while (getBoolean())
myRun { x.inc() }
myRun { x = 42 }
break
}
x = 42
}
else
myRun {
x = 42
}
x.inc()
}