Effects: add cfg-tests on inlined lambdas
========== Introduction of Effect System: 15/18
This commit is contained in:
+43
@@ -0,0 +1,43 @@
|
||||
// LANGUAGE_VERSION: 1.3
|
||||
|
||||
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()
|
||||
}
|
||||
Reference in New Issue
Block a user