Add support for contract feature in inliner

This commit is contained in:
Mikhael Bogdanov
2017-12-14 17:41:49 +01:00
parent 4890979476
commit 819a3a95b3
15 changed files with 610 additions and 72 deletions
@@ -0,0 +1,27 @@
// !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.*
fun box(): String {
val x: Int
myrun {
myrun {
x = 42
}
}
return if (x.inc() == 43) "OK" else "Fail: ${x.inc()}"
}