[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:
@@ -64,15 +64,15 @@ digraph nullability_kt {
|
||||
16 [label="Enter class QImpl" style="filled" fillcolor=red];
|
||||
subgraph cluster_9 {
|
||||
color=blue
|
||||
17 [label="Enter property" style="filled" fillcolor=red];
|
||||
18 [label="Access variable R|<local>/data|"];
|
||||
19 [label="Exit property" style="filled" fillcolor=red];
|
||||
17 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
18 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
|
||||
19 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
}
|
||||
subgraph cluster_10 {
|
||||
color=blue
|
||||
20 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
21 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
|
||||
22 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
20 [label="Enter property" style="filled" fillcolor=red];
|
||||
21 [label="Access variable R|<local>/data|"];
|
||||
22 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
23 [label="Exit class QImpl" style="filled" fillcolor=red];
|
||||
}
|
||||
@@ -112,15 +112,15 @@ digraph nullability_kt {
|
||||
31 [label="Enter class QImplMutable" style="filled" fillcolor=red];
|
||||
subgraph cluster_14 {
|
||||
color=blue
|
||||
32 [label="Enter property" style="filled" fillcolor=red];
|
||||
33 [label="Access variable R|<local>/data|"];
|
||||
34 [label="Exit property" style="filled" fillcolor=red];
|
||||
32 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
33 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
|
||||
34 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
}
|
||||
subgraph cluster_15 {
|
||||
color=blue
|
||||
35 [label="Enter function <init>" style="filled" fillcolor=red];
|
||||
36 [label="Delegated constructor call: super<R|kotlin/Any|>()" style="filled" fillcolor=yellow];
|
||||
37 [label="Exit function <init>" style="filled" fillcolor=red];
|
||||
35 [label="Enter property" style="filled" fillcolor=red];
|
||||
36 [label="Access variable R|<local>/data|"];
|
||||
37 [label="Exit property" style="filled" fillcolor=red];
|
||||
}
|
||||
38 [label="Exit class QImplMutable" style="filled" fillcolor=red];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user