Files
Brian Norman 17a1871b83 [FIR] Make sure the primary constructor is first in class CFG
The primary constructor of a class needs to be the first subgraph of the
class control-flow graph. Based on the Kotlin specification, class
initialization order goes first primary constructor, in-place
declarations (properties and init blocks), and then secondary
constructors. If the class doesn't have a primary constructor, then it
is just skipped in the order.

Unfortunately, the class control-flow graph had in-place declarations
first and then all constructors. Instead, we should treat the primary
constructor as the first in-place declaration, and then continue with
the existing processing as secondary constructors. This will guarantee
that super constructor calls have the correct property initialization
information.

^KT-65093 Fixed
2024-01-23 23:16:00 +00:00

264 lines
8.9 KiB
Plaintext
Vendored

digraph smartcastInByClause_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter file smartcastInByClause.kt" style="filled" fillcolor=red];
1 [label="Exit file smartcastInByClause.kt" style="filled" fillcolor=red];
}
0 -> {1} [color=green];
subgraph cluster_1 {
color=red
2 [label="Enter class A" style="filled" fillcolor=red];
subgraph cluster_2 {
color=blue
3 [label="Enter function <init>" style="filled" fillcolor=red];
4 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
5 [label="Exit function <init>" style="filled" fillcolor=red];
}
subgraph cluster_3 {
color=blue
6 [label="Enter property" style="filled" fillcolor=red];
7 [label="Access variable R|<local>/path|"];
8 [label="Exit property" style="filled" fillcolor=red];
}
subgraph cluster_4 {
color=blue
9 [label="Enter property" style="filled" fillcolor=red];
10 [label="Access variable R|<local>/index|"];
11 [label="Exit property" style="filled" fillcolor=red];
}
12 [label="Exit class A" style="filled" fillcolor=red];
}
2 -> {3} [color=green];
2 -> {12} [style=dotted];
2 -> {3 6 9} [style=dashed];
3 -> {4};
4 -> {5};
5 -> {6} [color=green];
6 -> {7};
7 -> {8};
8 -> {9} [color=green];
9 -> {10};
10 -> {11};
11 -> {12} [color=green];
subgraph cluster_5 {
color=red
13 [label="Enter class Base" style="filled" fillcolor=red];
14 [label="Exit class Base" style="filled" fillcolor=red];
}
13 -> {14} [color=green];
subgraph cluster_6 {
color=red
15 [label="Enter class Derived" style="filled" fillcolor=red];
subgraph cluster_7 {
color=blue
16 [label="Enter function <init>" style="filled" fillcolor=red];
17 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
18 [label="Exit function <init>" style="filled" fillcolor=red];
}
subgraph cluster_8 {
color=blue
19 [label="Enter property" style="filled" fillcolor=red];
20 [label="Access variable R|<local>/index|"];
21 [label="Exit property" style="filled" fillcolor=red];
}
22 [label="Exit class Derived" style="filled" fillcolor=red];
}
15 -> {16} [color=green];
15 -> {22} [style=dotted];
15 -> {16 19} [style=dashed];
16 -> {17};
17 -> {18};
18 -> {19} [color=green];
19 -> {20};
20 -> {21};
21 -> {22} [color=green];
subgraph cluster_9 {
color=red
23 [label="Enter function test" style="filled" fillcolor=red];
subgraph cluster_10 {
color=blue
24 [label="Enter block"];
25 [label="Access variable R|<local>/a|"];
26 [label="Enter safe call"];
27 [label="Access variable R|/A.path|"];
28 [label="Exit safe call"];
29 [label="Exit lhs of ?:"];
30 [label="Enter rhs of ?:"];
31 [label="Const: Null(null)"];
32 [label="Jump: ^test Null(null)"];
33 [label="Stub" style="filled" fillcolor=gray];
34 [label="Lhs of ?: is not null"];
35 [label="Exit ?:"];
36 [label="Variable declaration: lval path: R|kotlin/String|"];
subgraph cluster_11 {
color=blue
37 [label="Function call arguments enter"];
38 [label="Access variable R|<local>/a|"];
39 [label="Smart cast: R|<local>/a|"];
40 [label="Access variable R|/A.index|"];
41 [label="Function call arguments exit"];
}
42 [label="Function call: R|/takeInt|(...)" style="filled" fillcolor=yellow];
43 [label="Enter anonymous object"];
subgraph cluster_12 {
color=blue
44 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
subgraph cluster_13 {
color=blue
45 [label="Enter function <init>" style="filled" fillcolor=red];
46 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
47 [label="Exit function <init>" style="filled" fillcolor=red];
}
subgraph cluster_14 {
color=blue
48 [label="Enter field" style="filled" fillcolor=red];
subgraph cluster_15 {
color=blue
49 [label="Function call arguments enter"];
50 [label="Access variable R|<local>/a|"];
51 [label="Smart cast: R|<local>/a|"];
52 [label="Access variable R|/A.index|"];
53 [label="Function call arguments exit"];
}
54 [label="Function call: R|/Derived.Derived|(...)" style="filled" fillcolor=yellow];
55 [label="Exit field" style="filled" fillcolor=red];
}
subgraph cluster_16 {
color=blue
56 [label="Enter property" style="filled" fillcolor=red];
57 [label="Access variable R|<local>/a|"];
58 [label="Smart cast: R|<local>/a|"];
59 [label="Access variable R|/A.index|"];
60 [label="Exit property" style="filled" fillcolor=red];
}
61 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
}
62 [label="Exit anonymous object expression"];
63 [label="Jump: ^test object : R|Base| {
private constructor(): R|<anonymous>| {
super<R|kotlin/Any|>()
}
private final field $$delegate_0: R|Base| = R|/Derived.Derived|(R|<local>/a|.R|/A.index|)
public final val x: R|kotlin/Int| = R|<local>/a|.R|/A.index|
public get(): R|kotlin/Int|
public final fun foo(): R|kotlin/Unit| {
R|/takeInt|(R|<local>/a|.R|/A.index|)
}
}
"];
64 [label="Stub" style="filled" fillcolor=gray];
65 [label="Exit block" style="filled" fillcolor=gray];
}
66 [label="Exit function test" style="filled" fillcolor=red];
}
subgraph cluster_17 {
color=blue
67 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_18 {
color=blue
68 [label="Enter block"];
subgraph cluster_19 {
color=blue
69 [label="Function call arguments enter"];
70 [label="Access variable R|<local>/a|"];
71 [label="Smart cast: R|<local>/a|"];
72 [label="Access variable R|/A.index|"];
73 [label="Function call arguments exit"];
}
74 [label="Function call: R|/takeInt|(...)" style="filled" fillcolor=yellow];
75 [label="Exit block"];
}
76 [label="Exit function foo" style="filled" fillcolor=red];
}
23 -> {24};
24 -> {25};
25 -> {26 30};
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30 34};
30 -> {31};
31 -> {32};
32 -> {66};
32 -> {33} [style=dotted];
33 -> {35} [style=dotted];
34 -> {35};
35 -> {36};
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {42};
42 -> {43};
43 -> {44};
43 -> {62} [style=dotted];
43 -> {44} [style=dashed];
44 -> {45};
44 -> {48 56 67} [color=red];
44 -> {61} [style=dotted];
44 -> {45 48 56} [style=dashed];
45 -> {46};
46 -> {47};
47 -> {48} [color=green];
47 -> {61} [color=red];
48 -> {49};
49 -> {50};
50 -> {51};
51 -> {52};
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {56} [color=green];
55 -> {61} [color=red];
56 -> {57};
57 -> {58};
58 -> {59};
59 -> {60};
60 -> {61};
61 -> {62};
61 -> {67} [color=green];
61 -> {67} [style=dashed];
62 -> {63};
63 -> {66};
63 -> {64} [style=dotted];
64 -> {65} [style=dotted];
65 -> {66} [style=dotted];
67 -> {68};
68 -> {69};
69 -> {70};
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {74};
74 -> {75};
75 -> {76};
subgraph cluster_20 {
color=red
77 [label="Enter function takeInt" style="filled" fillcolor=red];
subgraph cluster_21 {
color=blue
78 [label="Enter block"];
79 [label="Exit block"];
}
80 [label="Exit function takeInt" style="filled" fillcolor=red];
}
77 -> {78};
78 -> {79};
79 -> {80};
}