Files
kotlin-fork/compiler/fir/analysis-tests/testData/resolve/cfg/complex.dot
T
Tianyu Geng 765cad8448 FIR checker: substitute type parameters in dispatch receiver type
Consider the following code:

```
fun test(a: List<String>) {
  a.first()
}
```

The dispatch receiver type of `first` in this case is `List<T>` before
this change. After this change, it's `List<String>`.

In addition, this change also replace the dispatch receiver type with
the more specific type if available. For example, consider the following

```
class MyList: ArrayList<String>()

fun test(a: MyList) {
  a.get(0)
}
```
The dispatch receiver type of `get` is `MyList`, instead of
`ArrayList<String>`. That is, a fake override is created in this case.
2021-09-17 01:59:06 +03:00

299 lines
11 KiB
Plaintext
Vendored

digraph complex_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function close" style="filled" fillcolor=red];
1 [label="Exit function close" style="filled" fillcolor=red];
}
0 -> {1};
subgraph cluster_1 {
color=red
2 [label="Enter class AutoCloseable" style="filled" fillcolor=red];
3 [label="Exit class AutoCloseable" style="filled" fillcolor=red];
}
2 -> {3} [color=green];
subgraph cluster_2 {
color=red
4 [label="Enter function addSuppressed" style="filled" fillcolor=red];
subgraph cluster_3 {
color=blue
5 [label="Enter block"];
6 [label="Exit block"];
}
7 [label="Exit function addSuppressed" style="filled" fillcolor=red];
}
4 -> {5};
5 -> {6};
6 -> {7};
subgraph cluster_4 {
color=red
8 [label="Enter function closeFinally" style="filled" fillcolor=red];
subgraph cluster_5 {
color=blue
9 [label="Enter block"];
subgraph cluster_6 {
color=blue
10 [label="Enter when"];
subgraph cluster_7 {
color=blue
11 [label="Enter when branch condition "];
12 [label="Access variable this@R|/closeFinally|"];
13 [label="Const: Null(null)"];
14 [label="Equality operator =="];
15 [label="Exit when branch condition"];
}
subgraph cluster_8 {
color=blue
16 [label="Enter when branch condition "];
17 [label="Access variable R|<local>/cause|"];
18 [label="Const: Null(null)"];
19 [label="Equality operator =="];
20 [label="Exit when branch condition"];
}
subgraph cluster_9 {
color=blue
21 [label="Enter when branch condition else"];
22 [label="Exit when branch condition"];
}
23 [label="Enter when branch result"];
subgraph cluster_10 {
color=blue
24 [label="Enter block"];
subgraph cluster_11 {
color=blue
25 [label="Try expression enter"];
subgraph cluster_12 {
color=blue
26 [label="Try main block enter"];
subgraph cluster_13 {
color=blue
27 [label="Enter block"];
28 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()"];
29 [label="Exit block"];
}
30 [label="Try main block exit"];
}
subgraph cluster_14 {
color=blue
31 [label="Catch enter"];
subgraph cluster_15 {
color=blue
32 [label="Enter block"];
33 [label="Access variable R|<local>/cause|"];
34 [label="Access variable R|<local>/closeException|"];
35 [label="Function call: R|<local>/cause|.R|/addSuppressed|(...)"];
36 [label="Exit block"];
}
37 [label="Catch exit"];
}
38 [label="Try expression exit"];
}
39 [label="Exit block"];
}
40 [label="Exit when branch result"];
41 [label="Enter when branch result"];
subgraph cluster_16 {
color=blue
42 [label="Enter block"];
43 [label="Function call: this@R|/closeFinally|.R|/AutoCloseable.close|()"];
44 [label="Exit block"];
}
45 [label="Exit when branch result"];
46 [label="Enter when branch result"];
subgraph cluster_17 {
color=blue
47 [label="Enter block"];
48 [label="Exit block"];
}
49 [label="Exit when branch result"];
50 [label="Exit when"];
}
51 [label="Jump: ^closeFinally when () {
==(this@R|/closeFinally|, Null(null)) -> {
}
==(R|<local>/cause|, Null(null)) -> {
this@R|/closeFinally|.R|/AutoCloseable.close|()
}
else -> {
try {
this@R|/closeFinally|.R|/AutoCloseable.close|()
}
catch (closeException: R|kotlin/Throwable|) {
R|<local>/cause|.R|/addSuppressed|(R|<local>/closeException|)
}
}
}
"];
52 [label="Stub" style="filled" fillcolor=gray];
53 [label="Exit block" style="filled" fillcolor=gray];
}
54 [label="Exit function closeFinally" style="filled" fillcolor=red];
}
8 -> {9};
9 -> {10};
10 -> {11};
11 -> {12};
12 -> {13};
13 -> {14};
14 -> {15};
15 -> {46 16};
16 -> {17};
17 -> {18};
18 -> {19};
19 -> {20};
20 -> {41 21};
21 -> {22};
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {26 31};
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30};
30 -> {38 31};
31 -> {32};
31 -> {54} [label=onUncaughtException];
32 -> {33};
33 -> {34};
34 -> {35};
35 -> {36};
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {50};
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {45};
45 -> {50};
46 -> {47};
47 -> {48};
48 -> {49};
49 -> {50};
50 -> {51};
51 -> {54};
51 -> {52} [style=dotted];
52 -> {53} [style=dotted];
53 -> {54} [style=dotted];
subgraph cluster_18 {
color=red
55 [label="Enter function firstIsInstanceOrNull" style="filled" fillcolor=red];
subgraph cluster_19 {
color=blue
56 [label="Enter block"];
subgraph cluster_20 {
color=blue
57 [label="Enter block"];
58 [label="Access variable this@R|/firstIsInstanceOrNull|"];
59 [label="Function call: this@R|/firstIsInstanceOrNull|.R|SubstitutionOverride<kotlin/collections/List.iterator: R|kotlin/collections/Iterator<CapturedType(*)>|>|()"];
60 [label="Variable declaration: lval <iterator>: R|kotlin/collections/Iterator<kotlin/Any?>|"];
subgraph cluster_21 {
color=blue
61 [label="Enter while loop"];
subgraph cluster_22 {
color=blue
62 [label="Enter loop condition"];
63 [label="Access variable R|<local>/<iterator>|"];
64 [label="Function call: R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.hasNext: R|kotlin/Boolean|>|()"];
65 [label="Exit loop condition"];
}
subgraph cluster_23 {
color=blue
66 [label="Enter loop block"];
subgraph cluster_24 {
color=blue
67 [label="Enter block"];
68 [label="Access variable R|<local>/<iterator>|"];
69 [label="Function call: R|<local>/<iterator>|.R|SubstitutionOverride<kotlin/collections/Iterator.next: R|kotlin/Any?|>|()"];
70 [label="Variable declaration: lval element: R|kotlin/Any?|"];
subgraph cluster_25 {
color=blue
71 [label="Enter when"];
subgraph cluster_26 {
color=blue
72 [label="Enter when branch condition "];
73 [label="Access variable R|<local>/element|"];
74 [label="Type operator: (R|<local>/element| is R|T|)"];
75 [label="Exit when branch condition"];
}
76 [label="Synthetic else branch"];
77 [label="Enter when branch result"];
subgraph cluster_27 {
color=blue
78 [label="Enter block"];
79 [label="Access variable R|<local>/element|"];
80 [label="Jump: ^firstIsInstanceOrNull R|<local>/element|"];
81 [label="Stub" style="filled" fillcolor=gray];
82 [label="Exit block" style="filled" fillcolor=gray];
}
83 [label="Exit when branch result" style="filled" fillcolor=gray];
84 [label="Exit when"];
}
85 [label="Exit block"];
}
86 [label="Exit loop block"];
}
87 [label="Exit whileloop"];
}
88 [label="Exit block"];
}
89 [label="Const: Null(null)"];
90 [label="Jump: ^firstIsInstanceOrNull Null(null)"];
91 [label="Stub" style="filled" fillcolor=gray];
92 [label="Exit block" style="filled" fillcolor=gray];
}
93 [label="Exit function firstIsInstanceOrNull" style="filled" fillcolor=red];
}
55 -> {56};
56 -> {57};
57 -> {58};
58 -> {59};
59 -> {60};
60 -> {61};
61 -> {62};
62 -> {63};
63 -> {64};
64 -> {65};
65 -> {87 66};
66 -> {67};
67 -> {68};
68 -> {69};
69 -> {70};
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {74};
74 -> {75};
75 -> {77 76};
76 -> {84};
77 -> {78};
78 -> {79};
79 -> {80};
80 -> {93};
80 -> {81} [style=dotted];
81 -> {82} [style=dotted];
82 -> {83} [style=dotted];
83 -> {84} [style=dotted];
84 -> {85};
85 -> {86};
86 -> {62} [color=green style=dashed];
87 -> {88};
88 -> {89};
89 -> {90};
90 -> {93};
90 -> {91} [style=dotted];
91 -> {92} [style=dotted];
92 -> {93} [style=dotted];
}