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:
Alexander Udalov
2019-11-04 20:13:25 +01:00
parent 5c4b47c336
commit 66e19b13ce
18 changed files with 116 additions and 48 deletions
@@ -1,9 +1,9 @@
// !LANGUAGE: +AllowContractsForCustomFunctions +UseCallsInPlaceEffect +ReadDeserializedContracts
// !USE_EXPERIMENTAL: kotlin.contracts.ExperimentalContracts
// IGNORE_BACKEND: JVM_IR
// IGNORE_BACKEND_MULTI_MODULE: JVM_IR
// IGNORE_BACKEND: NATIVE
// FILE: 1.kt
package test
import kotlin.contracts.*
@@ -16,9 +16,9 @@ public inline fun <R> myrun(block: () -> R): R {
return block()
}
// FILE: 2.kt
// NO_CHECK_LAMBDA_INLINING
import test.*
fun box(): String {
@@ -30,4 +30,4 @@ fun box(): String {
}()
}
return if (res == 42 && x.inc() == 43) "OK" else "Fail: ${x.inc()}"
}
}