Files
kotlin-fork/compiler/testData/diagnostics/testsWithStdLib/smartcasts/lambdaInCallArgs.fir.kt
T
pyos 402ea98e02 FIR DFA: align FirLocalVariableAssignmentAnalyzer with the graph builder
I.e. maintain a set of seen lambdas where each marked as either "data
flow only" or "both data and control flow". The latter are truly
parallel with the function being analyzed, while the former have
technically already terminated, we just don't know the types inside them
because they may not have been analyzed yet.
2022-12-08 10:19:34 +00:00

50 lines
1.0 KiB
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 = "" },
<!SMARTCAST_IMPOSSIBLE!>x<!>.length // can be 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
)
}
}
fun test_4() {
var x: String? = null
if (x != null) {
foo(
x.length, // stable smartcast
run { x = null },
<!SMARTCAST_IMPOSSIBLE!>x<!>.length // either unstable or not a smartcast
)
}
}