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,30 @@
// !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.*
class A {
val z: String
init {
myrun {
z = "OK"
}
}
}
fun box(): String {
return A().z
}