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
@@ -63,14 +63,14 @@ digraph inplaceLambdaInControlFlowExpressions_kt {
24 [label="Postponed enter to lambda"];
subgraph cluster_9 {
color=blue
33 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
34 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_10 {
color=blue
34 [label="Enter block"];
35 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
36 [label="Exit block"];
35 [label="Enter block"];
36 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
37 [label="Exit block"];
}
37 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
38 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
25 [label="Postponed exit from lambda"];
26 [label="Function call: R|kotlin/run|<R|kotlin/String|>(...)"];
@@ -84,6 +84,7 @@ digraph inplaceLambdaInControlFlowExpressions_kt {
}
32 [label="Exit function test_1" style="filled" fillcolor=red];
}
33 [label="Merge postponed lambda exits"];
9 -> {10};
10 -> {11};
11 -> {12};
@@ -99,89 +100,89 @@ digraph inplaceLambdaInControlFlowExpressions_kt {
21 -> {29};
22 -> {23};
23 -> {24};
24 -> {33};
24 -> {34};
24 -> {25} [color=red];
24 -> {33} [style=dashed];
24 -> {34} [style=dashed];
25 -> {26};
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30};
29 -> {33 30};
30 -> {31};
31 -> {32};
33 -> {34};
34 -> {35};
35 -> {36};
36 -> {37};
37 -> {25} [color=green];
37 -> {38};
38 -> {33} [color=red];
38 -> {25} [color=green];
subgraph cluster_11 {
color=red
38 [label="Enter function test_2" style="filled" fillcolor=red];
39 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_12 {
color=blue
39 [label="Enter block"];
40 [label="Enter block"];
subgraph cluster_13 {
color=blue
40 [label="Try expression enter"];
41 [label="Try expression enter"];
subgraph cluster_14 {
color=blue
41 [label="Try main block enter"];
42 [label="Try main block enter"];
subgraph cluster_15 {
color=blue
42 [label="Enter block"];
43 [label="Postponed enter to lambda"];
43 [label="Enter block"];
44 [label="Postponed enter to lambda"];
subgraph cluster_16 {
color=blue
58 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
59 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_17 {
color=blue
59 [label="Enter block"];
60 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
61 [label="Exit block"];
60 [label="Enter block"];
61 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
62 [label="Exit block"];
}
62 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
63 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
44 [label="Postponed exit from lambda"];
45 [label="Function call: R|kotlin/run|<R|kotlin/String|>(...)"];
46 [label="Exit block"];
45 [label="Postponed exit from lambda"];
46 [label="Function call: R|kotlin/run|<R|kotlin/String|>(...)"];
47 [label="Exit block"];
}
47 [label="Try main block exit"];
48 [label="Try main block exit"];
}
subgraph cluster_18 {
color=blue
48 [label="Catch enter"];
49 [label="Catch enter"];
subgraph cluster_19 {
color=blue
49 [label="Enter block"];
50 [label="Const: String()"];
51 [label="Exit block"];
50 [label="Enter block"];
51 [label="Const: String()"];
52 [label="Exit block"];
}
52 [label="Catch exit"];
53 [label="Catch exit"];
}
53 [label="Try expression exit"];
54 [label="Try expression exit"];
}
54 [label="Call arguments union" style="filled" fillcolor=yellow];
55 [label="Variable declaration: lval x: R|kotlin/String|"];
56 [label="Exit block"];
55 [label="Call arguments union" style="filled" fillcolor=yellow];
56 [label="Variable declaration: lval x: R|kotlin/String|"];
57 [label="Exit block"];
}
57 [label="Exit function test_2" style="filled" fillcolor=red];
58 [label="Exit function test_2" style="filled" fillcolor=red];
}
38 -> {39};
39 -> {40};
40 -> {41 48};
41 -> {42};
40 -> {41};
41 -> {42 49};
42 -> {43};
43 -> {58};
43 -> {44} [color=red];
43 -> {58} [style=dashed];
44 -> {45};
43 -> {44};
44 -> {59};
44 -> {45} [color=red];
44 -> {59} [style=dashed];
45 -> {46};
46 -> {47};
47 -> {53 48};
48 -> {49};
48 -> {57} [label=onUncaughtException];
47 -> {48};
48 -> {54 49};
49 -> {50};
49 -> {58} [label=onUncaughtException];
50 -> {51};
51 -> {52};
52 -> {53};
@@ -189,56 +190,57 @@ digraph inplaceLambdaInControlFlowExpressions_kt {
54 -> {55};
55 -> {56};
56 -> {57};
58 -> {59};
57 -> {58};
59 -> {60};
60 -> {61};
61 -> {62};
62 -> {54} [color=red];
62 -> {44} [color=green];
62 -> {63};
63 -> {55} [color=red];
63 -> {45} [color=green];
subgraph cluster_20 {
color=red
63 [label="Enter function test_3" style="filled" fillcolor=red];
64 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_21 {
color=blue
64 [label="Enter block"];
65 [label="Postponed enter to lambda"];
65 [label="Enter block"];
66 [label="Postponed enter to lambda"];
subgraph cluster_22 {
color=blue
73 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
74 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_23 {
color=blue
74 [label="Enter block"];
75 [label="Function call: R|/materialize|<R|kotlin/String?|>()"];
76 [label="Exit block"];
75 [label="Enter block"];
76 [label="Function call: R|/materialize|<R|kotlin/String?|>()"];
77 [label="Exit block"];
}
77 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
78 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
66 [label="Postponed exit from lambda"];
67 [label="Function call: R|kotlin/run|<R|kotlin/String?|>(...)"];
68 [label="Check not null: R|kotlin/run|<R|kotlin/String?|>(...)!!"];
69 [label="Call arguments union" style="filled" fillcolor=yellow];
70 [label="Variable declaration: lval x: R|kotlin/String|"];
71 [label="Exit block"];
67 [label="Postponed exit from lambda"];
68 [label="Function call: R|kotlin/run|<R|kotlin/String?|>(...)"];
69 [label="Check not null: R|kotlin/run|<R|kotlin/String?|>(...)!!"];
70 [label="Call arguments union" style="filled" fillcolor=yellow];
71 [label="Variable declaration: lval x: R|kotlin/String|"];
72 [label="Exit block"];
}
72 [label="Exit function test_3" style="filled" fillcolor=red];
73 [label="Exit function test_3" style="filled" fillcolor=red];
}
63 -> {64};
64 -> {65};
65 -> {73};
65 -> {66} [color=red];
65 -> {73} [style=dashed];
66 -> {67};
65 -> {66};
66 -> {74};
66 -> {67} [color=red];
66 -> {74} [style=dashed];
67 -> {68};
68 -> {69};
69 -> {70};
70 -> {71};
71 -> {72};
73 -> {74};
72 -> {73};
74 -> {75};
75 -> {76};
76 -> {77};
77 -> {69} [color=red];
77 -> {66} [color=green];
77 -> {78};
78 -> {70} [color=red];
78 -> {67} [color=green];
}