FIR CFG: mark variables touched by not-in-place lambdas in all scopes

This commit is contained in:
pyos
2022-06-13 15:42:20 +02:00
committed by teamcity
parent 63b0708ed5
commit 25f66b4e0e
7 changed files with 58 additions and 4 deletions
@@ -0,0 +1,22 @@
// FIR_IDENTICAL
import kotlin.contracts.*
@Suppress("OPT_IN_USAGE_ERROR", "OPT_IN_USAGE_FUTURE_ERROR")
fun exactlyOnce(f: () -> Unit) {
contract {
callsInPlace(f, InvocationKind.EXACTLY_ONCE)
}
f()
}
fun test() {
var s: String? = ""
if (s != null) {
val block: () -> Unit
exactlyOnce {
block = { s = null }
}
block()
<!SMARTCAST_IMPOSSIBLE!>s<!>.length
}
}