FIR CFG: join/unify data flow from postponed lambdas at each level

For example:

    foo(
        // `if` joins A & B
        if (condition)
            run { ... } // A
        else
            run { ... }, // B
        run { ... } // C
    ) // `foo` unifies `A & B` and `C`, so if it is not resolved itself,
      // further `if`s, `when`s, safe calls outside it, etc. continue
      // building the correct type predicate until the next completed
      // call.

^KT-44512 Fixed
This commit is contained in:
pyos
2022-06-13 14:17:34 +02:00
committed by teamcity
parent 755c54553a
commit 63b0708ed5
17 changed files with 720 additions and 623 deletions
@@ -21,7 +21,7 @@ fun test2(x: String?) {
foo(
id(run { x as String; n() }),
someCompletedCall(1),
run { x.length; 123 } // Bad (resolution order undefined)
run { x<!UNSAFE_CALL!>.<!>length; 123 } // Bad (resolution order undefined)
)
x.length // OK (x as String unconditional)
}
@@ -32,7 +32,7 @@ fun test3(x: String?) {
if (true) 1 else 2,
run { x<!UNSAFE_CALL!>.<!>length; 123 } // Bad (resolution order undefined)
)
x<!UNSAFE_CALL!>.<!>length // OK (x as String unconditional)
x.length // OK (x as String unconditional)
}
fun test4(x: String?) {
@@ -41,9 +41,9 @@ fun test4(x: String?) {
foo(
id(if (true) run { p = null; n() } else run { n() }),
1,
run { p.length; 123 } // Bad (p = null possible)
run { p<!UNSAFE_CALL!>.<!>length; 123 } // Bad (p = null possible)
)
p.length // Bad (p = null possible)
p<!UNSAFE_CALL!>.<!>length // Bad (p = null possible)
}
}
@@ -53,7 +53,7 @@ fun test5(x: String?, y: String?) {
1,
run { "" }
)
x.length // Bad (x as String conditional)
x<!UNSAFE_CALL!>.<!>length // Bad (x as String conditional)
}
fun test6(x: String?) {