Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/smartcasts/lambdaInCallArgs.fir.kt
T
Tianyu Geng 2e049c1208 FIR DFA: fix CFG with normal arg after lambda [KT-46825]
The fix is a bit hacky, but it's very simple. In addition, it still does
not handle the case where the receiver is a lambda function. But such
case seems to be fairly rare in practice.
2021-06-29 10:46:41 +03:00

39 lines
737 B
Kotlin
Vendored

fun foo(x: Int, y: Any?, z: Int) {}
fun myRun(block: () -> Unit): Any? {
return null
}
fun test_1() {
var x: String? = null
if (x != null) {
foo(
x.length, // stable smartcast
run { x = "" },
x.length // stable smartcast
)
}
}
fun test_2() {
var x: String? = null
if (x != null) {
foo(
x.length, // stable smartcast
myRun { x = "" },
<!SMARTCAST_IMPOSSIBLE!>x<!>.length // unstable smartcast
)
}
}
fun test_3() {
var x: String? = null
if (x != null) {
foo(
x.length, // stable smartcast
{ x = "" },
x.length // stable smartcast
)
}
}