IR: create shared variables for val-variables when needed
This is possible when a lambda's contract guarantees initialization of a variable.
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect +ReadDeserializedContracts
|
||||
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
|
||||
// IGNORE_BACKEND: JVM_IR, NATIVE, JS_IR
|
||||
// IGNORE_BACKEND_MULTI_MODULE: JVM_IR
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
import kotlin.contracts.*
|
||||
@@ -17,6 +18,7 @@ public inline fun myrun(noinline block: () -> Unit): Unit {
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
@@ -25,4 +27,4 @@ fun box(): String {
|
||||
x = 42L
|
||||
}
|
||||
return if (x != 42L) "FAIL" else "OK"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user