Add support for contract feature in inliner
This commit is contained in:
+27
@@ -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 test(s: String) = s
|
||||
|
||||
fun box(): String {
|
||||
val x: String
|
||||
myrun {
|
||||
x = try { test("OK") } catch (e: Exception) { test("fail") }
|
||||
}
|
||||
return x
|
||||
}
|
||||
Reference in New Issue
Block a user