Files
kotlin-fork/compiler/fir/analysis-tests/testData/resolve/cfg/postponedLambdaInConstructor.dot
T
pyos aadea0e26f FIR CFA: properly visit subgraphs in checkers
Interpretation: a graph A is a subgraph of B if information available at
nodes of A depends on the paths taken in B. For example, local classes
are subgraphs of a graph in which they are declared, and members of
those classes are subgraphs of the local class itself - because these
members can reference captured values.

Consequences:

 * if graph G is a subgraph of node N, then G is a subgraph of N's
   owner;
 * `ControlFlowAnalysisDiagnosticComponent` will only visit root graphs;
 * `graph.traverse` will ignore subgraph boundaries, as if all subgraphs
   are inlined into one huge root graph;
 * if a control flow checker needs information from a declaration to
   which a graph is attached, it must look at subgraphs explicitly.

For example, consider the `callsInPlace` checker. When a function
has a `callsInPlace` contract and a local declaration, the checker must
visit that local declaration to ensure it does not capture the allegedly
called-in-place argument - hence `graph.traverse` will look at the
nodes. However, the local declaration can also be a function with its
own `callsInPlace` contracts, so the checker should also run for it in
isolation. If that sounds quadratic, that's because unfortunately it is.
2023-01-10 15:40:48 +02:00

111 lines
3.7 KiB
Plaintext
Vendored

digraph postponedLambdaInConstructor_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function <init>" style="filled" fillcolor=red];
1 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
2 [label="Exit function <init>" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
subgraph cluster_1 {
color=red
3 [label="Enter class A" style="filled" fillcolor=red];
4 [label="Exit class A" style="filled" fillcolor=red];
}
3 -> {4} [color=green];
subgraph cluster_2 {
color=red
5 [label="Enter function <init>" style="filled" fillcolor=red];
6 [label="Access variable R|<local>/s|"];
7 [label="Postponed enter to lambda"];
subgraph cluster_3 {
color=blue
12 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_4 {
color=blue
13 [label="Enter block"];
14 [label="Exit anonymous function expression"];
subgraph cluster_5 {
color=blue
17 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_6 {
color=blue
18 [label="Enter block"];
19 [label="Access variable R|<local>/it|"];
20 [label="Exit block"];
}
21 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
15 [label="Exit block"];
}
16 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
8 [label="Postponed exit from lambda"];
9 [label="Function call: R|<local>/s|.R|kotlin/let|<R|kotlin/String|, R|() -> kotlin/String|>(...)" style="filled" fillcolor=yellow];
10 [label="Delegated constructor call: super<R|A|>(...)" style="filled" fillcolor=yellow];
11 [label="Exit function <init>" style="filled" fillcolor=red];
}
5 -> {6};
6 -> {7};
7 -> {9 12};
7 -> {8} [style=dotted];
7 -> {12} [style=dashed];
8 -> {9} [color=green];
8 -> {10} [color=red];
9 -> {10};
10 -> {11};
12 -> {13};
13 -> {14};
14 -> {15 17};
14 -> {17} [style=dashed];
15 -> {16};
16 -> {8};
17 -> {18};
18 -> {19};
19 -> {20};
20 -> {21};
subgraph cluster_7 {
color=red
25 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_8 {
color=blue
26 [label="Enter block"];
27 [label="Function call: this@R|/B|.R|/B.foo|()" style="filled" fillcolor=yellow];
28 [label="Exit block"];
}
29 [label="Exit function foo" style="filled" fillcolor=red];
}
25 -> {26};
26 -> {27};
27 -> {28};
28 -> {29};
subgraph cluster_9 {
color=red
30 [label="Enter class B" style="filled" fillcolor=red];
31 [label="Part of class initialization"];
subgraph cluster_10 {
color=blue
22 [label="Enter property" style="filled" fillcolor=red];
23 [label="Access variable R|<local>/s|"];
24 [label="Exit property" style="filled" fillcolor=red];
}
32 [label="Exit class B" style="filled" fillcolor=red];
}
30 -> {31} [color=green];
31 -> {22} [color=green];
31 -> {32} [style=dotted];
31 -> {22} [style=dashed];
22 -> {23};
23 -> {24};
24 -> {32} [color=green];
}