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:
+4
-5
@@ -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,8 +16,8 @@ public inline fun <R> myrun(block: () -> R): R {
|
||||
return block()
|
||||
}
|
||||
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun test(b: Boolean): Int {
|
||||
@@ -34,8 +34,7 @@ fun test(b: Boolean): Int {
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
|
||||
if (test(true) != 1) return "Fail 1"
|
||||
if (test(false) != -1) return "Fail 2"
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user