[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
This commit is contained in:
+51
-51
@@ -50,28 +50,28 @@ digraph propertiesAndInitBlocks_kt {
|
||||
21 [label="Enter class InitializerLocalClass" style="filled" fillcolor=red];
|
||||
subgraph cluster_9 {
|
||||
color=blue
|
||||
22 [label="Enter init block" style="filled" fillcolor=red];
|
||||
subgraph cluster_10 {
|
||||
color=blue
|
||||
23 [label="Enter block"];
|
||||
subgraph cluster_11 {
|
||||
color=blue
|
||||
24 [label="Function call arguments enter"];
|
||||
25 [label="Function call arguments exit"];
|
||||
}
|
||||
26 [label="Function call: R|java/lang/Exception.Exception|()" style="filled" fillcolor=yellow];
|
||||
27 [label="Throw: throw R|java/lang/Exception.Exception|()"];
|
||||
28 [label="Stub" style="filled" fillcolor=gray];
|
||||
29 [label="Const: Int(1)" style="filled" fillcolor=gray];
|
||||
30 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
31 [label="Exit init block" style="filled" fillcolor=gray];
|
||||
22 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
23 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
|
||||
24 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
}
|
||||
subgraph cluster_12 {
|
||||
subgraph cluster_10 {
|
||||
color=blue
|
||||
32 [label="Enter function <init>" style="filled" fillcolor=gray];
|
||||
33 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=gray];
|
||||
34 [label="Exit function <init>" style="filled" fillcolor=gray];
|
||||
25 [label="Enter init block" style="filled" fillcolor=red];
|
||||
subgraph cluster_11 {
|
||||
color=blue
|
||||
26 [label="Enter block"];
|
||||
subgraph cluster_12 {
|
||||
color=blue
|
||||
27 [label="Function call arguments enter"];
|
||||
28 [label="Function call arguments exit"];
|
||||
}
|
||||
29 [label="Function call: R|java/lang/Exception.Exception|()" style="filled" fillcolor=yellow];
|
||||
30 [label="Throw: throw R|java/lang/Exception.Exception|()"];
|
||||
31 [label="Stub" style="filled" fillcolor=gray];
|
||||
32 [label="Const: Int(1)" style="filled" fillcolor=gray];
|
||||
33 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
34 [label="Exit init block" style="filled" fillcolor=gray];
|
||||
}
|
||||
35 [label="Exit class InitializerLocalClass" style="filled" fillcolor=gray];
|
||||
}
|
||||
@@ -181,17 +181,17 @@ digraph propertiesAndInitBlocks_kt {
|
||||
19 -> {20} [style=dotted];
|
||||
20 -> {52} [style=dotted];
|
||||
21 -> {22};
|
||||
21 -> {32} [color=red];
|
||||
21 -> {25} [color=red];
|
||||
21 -> {35} [style=dotted];
|
||||
21 -> {22 32} [style=dashed];
|
||||
21 -> {22 25} [style=dashed];
|
||||
22 -> {23};
|
||||
23 -> {24};
|
||||
24 -> {25};
|
||||
24 -> {25} [color=green];
|
||||
25 -> {26};
|
||||
26 -> {27};
|
||||
27 -> {28} [style=dotted];
|
||||
28 -> {29} [style=dotted];
|
||||
29 -> {30} [style=dotted];
|
||||
27 -> {28};
|
||||
28 -> {29};
|
||||
29 -> {30};
|
||||
30 -> {31} [style=dotted];
|
||||
31 -> {32} [style=dotted];
|
||||
32 -> {33} [style=dotted];
|
||||
@@ -317,27 +317,27 @@ digraph propertiesAndInitBlocks_kt {
|
||||
101 [label="Enter class GetterLocalClass" style="filled" fillcolor=red];
|
||||
subgraph cluster_35 {
|
||||
color=blue
|
||||
102 [label="Enter init block" style="filled" fillcolor=red];
|
||||
subgraph cluster_36 {
|
||||
color=blue
|
||||
103 [label="Enter block"];
|
||||
subgraph cluster_37 {
|
||||
color=blue
|
||||
104 [label="Function call arguments enter"];
|
||||
105 [label="Function call arguments exit"];
|
||||
}
|
||||
106 [label="Function call: R|java/lang/Exception.Exception|()" style="filled" fillcolor=yellow];
|
||||
107 [label="Throw: throw R|java/lang/Exception.Exception|()"];
|
||||
108 [label="Stub" style="filled" fillcolor=gray];
|
||||
109 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
110 [label="Exit init block" style="filled" fillcolor=gray];
|
||||
102 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
103 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
|
||||
104 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
}
|
||||
subgraph cluster_38 {
|
||||
subgraph cluster_36 {
|
||||
color=blue
|
||||
111 [label="Enter function <init>" style="filled" fillcolor=gray];
|
||||
112 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=gray];
|
||||
113 [label="Exit function <init>" style="filled" fillcolor=gray];
|
||||
105 [label="Enter init block" style="filled" fillcolor=red];
|
||||
subgraph cluster_37 {
|
||||
color=blue
|
||||
106 [label="Enter block"];
|
||||
subgraph cluster_38 {
|
||||
color=blue
|
||||
107 [label="Function call arguments enter"];
|
||||
108 [label="Function call arguments exit"];
|
||||
}
|
||||
109 [label="Function call: R|java/lang/Exception.Exception|()" style="filled" fillcolor=yellow];
|
||||
110 [label="Throw: throw R|java/lang/Exception.Exception|()"];
|
||||
111 [label="Stub" style="filled" fillcolor=gray];
|
||||
112 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
113 [label="Exit init block" style="filled" fillcolor=gray];
|
||||
}
|
||||
114 [label="Exit class GetterLocalClass" style="filled" fillcolor=gray];
|
||||
}
|
||||
@@ -347,17 +347,17 @@ digraph propertiesAndInitBlocks_kt {
|
||||
98 -> {101} [style=dashed];
|
||||
99 -> {100};
|
||||
101 -> {102};
|
||||
101 -> {111} [color=red];
|
||||
101 -> {105} [color=red];
|
||||
101 -> {114} [style=dotted];
|
||||
101 -> {102 111} [style=dashed];
|
||||
101 -> {102 105} [style=dashed];
|
||||
102 -> {103};
|
||||
103 -> {104};
|
||||
104 -> {105};
|
||||
104 -> {105} [color=green];
|
||||
105 -> {106};
|
||||
106 -> {107};
|
||||
107 -> {108} [style=dotted];
|
||||
108 -> {109} [style=dotted];
|
||||
109 -> {110} [style=dotted];
|
||||
107 -> {108};
|
||||
108 -> {109};
|
||||
109 -> {110};
|
||||
110 -> {111} [style=dotted];
|
||||
111 -> {112} [style=dotted];
|
||||
112 -> {113} [style=dotted];
|
||||
|
||||
Reference in New Issue
Block a user