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
@@ -69,16 +69,16 @@ digraph incorrectSmartcastToNothing_kt {
33 [label="Postponed enter to lambda"];
subgraph cluster_10 {
color=blue
43 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
45 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_11 {
color=blue
44 [label="Enter block"];
45 [label="Access variable R|<local>/it|"];
46 [label="Const: String(main.kts.compiled.cache)"];
47 [label="Function call: R|java/io/File.File|(...)"];
48 [label="Exit block"];
46 [label="Enter block"];
47 [label="Access variable R|<local>/it|"];
48 [label="Const: String(main.kts.compiled.cache)"];
49 [label="Function call: R|java/io/File.File|(...)"];
50 [label="Exit block"];
}
49 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
51 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
34 [label="Postponed exit from lambda"];
35 [label="Function call: $subj$.R|kotlin/let|<R|java/io/File|, R|java/io/File|>(...)"];
@@ -93,6 +93,8 @@ digraph incorrectSmartcastToNothing_kt {
}
42 [label="Exit function test" style="filled" fillcolor=red];
}
43 [label="Merge postponed lambda exits"];
44 [label="Merge postponed lambda exits"];
4 -> {5};
5 -> {6};
6 -> {7};
@@ -122,23 +124,25 @@ digraph incorrectSmartcastToNothing_kt {
30 -> {31};
31 -> {32 36};
32 -> {33};
33 -> {43};
33 -> {45};
33 -> {34} [color=red];
33 -> {43} [style=dashed];
33 -> {45} [style=dashed];
34 -> {35};
35 -> {36};
36 -> {37};
36 -> {43 37};
37 -> {38};
38 -> {39};
39 -> {40};
39 -> {44 40};
40 -> {41};
41 -> {42};
43 -> {44};
44 -> {45};
43 -> {44} [color=red];
45 -> {46};
46 -> {47};
47 -> {48};
48 -> {49};
49 -> {34} [color=green];
49 -> {50};
50 -> {51};
51 -> {43} [color=red];
51 -> {34} [color=green];
}
@@ -135,14 +135,14 @@ digraph lambdaInWhenBranch_kt {
48 [label="Postponed enter to lambda"];
subgraph cluster_18 {
color=blue
81 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
82 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_19 {
color=blue
82 [label="Enter block"];
83 [label="Access variable R|<local>/it|"];
84 [label="Exit block"];
83 [label="Enter block"];
84 [label="Access variable R|<local>/it|"];
85 [label="Exit block"];
}
85 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
86 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
49 [label="Postponed exit from lambda"];
50 [label="Function call: String().R|kotlin/let|<R|kotlin/String|, R|kotlin/String|>(...)"];
@@ -195,6 +195,7 @@ digraph lambdaInWhenBranch_kt {
}
80 [label="Exit function foo" style="filled" fillcolor=red];
}
81 [label="Merge postponed lambda exits"];
28 -> {29};
29 -> {30};
30 -> {31};
@@ -215,14 +216,14 @@ digraph lambdaInWhenBranch_kt {
45 -> {46};
46 -> {47};
47 -> {48};
48 -> {81};
48 -> {82};
48 -> {49} [color=red];
48 -> {81} [style=dashed];
48 -> {82} [style=dashed];
49 -> {50};
50 -> {51};
51 -> {52};
52 -> {53};
53 -> {54};
53 -> {81 54};
54 -> {55};
55 -> {56};
56 -> {57};
@@ -249,10 +250,11 @@ digraph lambdaInWhenBranch_kt {
77 -> {78};
78 -> {79};
79 -> {80};
81 -> {82};
82 -> {83};
83 -> {84};
84 -> {85};
85 -> {49} [color=green];
85 -> {86};
86 -> {81} [color=red];
86 -> {49} [color=green];
}