[FIR] Split FirAnonymousObject to expression and declaration

This commit is contained in:
Dmitriy Novozhilov
2021-06-09 14:31:16 +03:00
parent ad89d43186
commit 85b844c748
41 changed files with 769 additions and 546 deletions
@@ -46,7 +46,8 @@ digraph innerClassInAnonymousObject_kt {
color=red
14 [label="Enter property" style="filled" fillcolor=red];
15 [label="Exit anonymous object"];
16 [label="Exit property" style="filled" fillcolor=red];
16 [label="Exit anonymous object expression"];
17 [label="Exit property" style="filled" fillcolor=red];
}
subgraph cluster_6 {
color=blue
@@ -58,6 +59,7 @@ digraph innerClassInAnonymousObject_kt {
15 -> {16};
15 -> {0 12} [color=green];
15 -> {0 12} [style=dashed];
16 -> {17};
12 -> {13} [color=green];
}
@@ -54,20 +54,21 @@ digraph localClassesWithImplicit_kt {
}
22 [label="Exit local class test"];
23 [label="Exit anonymous object"];
24 [label="Variable declaration: lval x: R|<anonymous>|"];
25 [label="Exit block"];
24 [label="Exit anonymous object expression"];
25 [label="Variable declaration: lval x: R|<anonymous>|"];
26 [label="Exit block"];
}
subgraph cluster_7 {
color=blue
29 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
30 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
30 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
31 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
}
subgraph cluster_8 {
color=blue
27 [label="Enter class A" style="filled" fillcolor=red];
28 [label="Exit class A" style="filled" fillcolor=red];
28 [label="Enter class A" style="filled" fillcolor=red];
29 [label="Exit class A" style="filled" fillcolor=red];
}
26 [label="Exit function test" style="filled" fillcolor=red];
27 [label="Exit function test" style="filled" fillcolor=red];
}
7 -> {8};
8 -> {9};
@@ -79,91 +80,92 @@ digraph localClassesWithImplicit_kt {
14 -> {21};
15 -> {16};
16 -> {17};
17 -> {26};
17 -> {27};
17 -> {18} [style=dotted];
18 -> {19} [style=dotted];
19 -> {20} [style=dotted];
20 -> {21} [style=dotted];
21 -> {22};
21 -> {31 34 69 87} [color=red];
21 -> {32 35 70 88} [color=red];
22 -> {23};
22 -> {94 97 132 150} [color=red];
22 -> {31 34 69 87 27} [color=green];
22 -> {31 34 69 87 27} [style=dashed];
22 -> {95 98 133 151} [color=red];
22 -> {32 35 70 88 28} [color=green];
22 -> {32 35 70 88 28} [style=dashed];
23 -> {24};
23 -> {94 97 132 150 29} [color=green];
23 -> {94 97 132 150 29} [style=dashed];
23 -> {95 98 133 151 30} [color=green];
23 -> {95 98 133 151 30} [style=dashed];
24 -> {25};
25 -> {26};
27 -> {28} [color=green];
29 -> {30} [color=green];
26 -> {27};
28 -> {29} [color=green];
30 -> {31} [color=green];
subgraph cluster_9 {
color=red
31 [label="Enter function <init>" style="filled" fillcolor=red];
32 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
33 [label="Exit function <init>" style="filled" fillcolor=red];
32 [label="Enter function <init>" style="filled" fillcolor=red];
33 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
34 [label="Exit function <init>" style="filled" fillcolor=red];
}
31 -> {32};
32 -> {33};
33 -> {34};
subgraph cluster_10 {
color=red
34 [label="Enter function foo" style="filled" fillcolor=red];
35 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_11 {
color=blue
35 [label="Enter block"];
36 [label="Postponed enter to lambda"];
36 [label="Enter block"];
37 [label="Postponed enter to lambda"];
subgraph cluster_12 {
color=blue
43 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
44 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_13 {
color=blue
44 [label="Enter block"];
45 [label="Access variable R|<local>/a|"];
46 [label="Access variable R|kotlin/String.length|"];
45 [label="Enter block"];
46 [label="Access variable R|<local>/a|"];
47 [label="Access variable R|kotlin/String.length|"];
subgraph cluster_14 {
color=blue
47 [label="Enter when"];
48 [label="Enter when"];
subgraph cluster_15 {
color=blue
48 [label="Enter when branch condition "];
49 [label="Access variable R|<local>/b|"];
50 [label="Type operator: (R|<local>/b| is R|kotlin/String|)"];
51 [label="Exit when branch condition"];
49 [label="Enter when branch condition "];
50 [label="Access variable R|<local>/b|"];
51 [label="Type operator: (R|<local>/b| is R|kotlin/String|)"];
52 [label="Exit when branch condition"];
}
subgraph cluster_16 {
color=blue
52 [label="Enter when branch condition else"];
53 [label="Exit when branch condition"];
53 [label="Enter when branch condition else"];
54 [label="Exit when branch condition"];
}
54 [label="Enter when branch result"];
55 [label="Enter when branch result"];
subgraph cluster_17 {
color=blue
55 [label="Enter block"];
56 [label="Const: Int(1)"];
57 [label="Exit block"];
56 [label="Enter block"];
57 [label="Const: Int(1)"];
58 [label="Exit block"];
}
58 [label="Exit when branch result"];
59 [label="Enter when branch result"];
59 [label="Exit when branch result"];
60 [label="Enter when branch result"];
subgraph cluster_18 {
color=blue
60 [label="Enter block"];
61 [label="Access variable R|<local>/b|"];
62 [label="Access variable R|kotlin/String.length|"];
63 [label="Function call: this@R|/A|.R|<local>/bar|()"];
64 [label="Exit block"];
61 [label="Enter block"];
62 [label="Access variable R|<local>/b|"];
63 [label="Access variable R|kotlin/String.length|"];
64 [label="Function call: this@R|/A|.R|<local>/bar|()"];
65 [label="Exit block"];
}
65 [label="Exit when branch result"];
66 [label="Exit when"];
66 [label="Exit when branch result"];
67 [label="Exit when"];
}
67 [label="Exit block"];
68 [label="Exit block"];
}
68 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
69 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
37 [label="Postponed exit from lambda"];
38 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"];
39 [label="Jump: ^foo R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=UNKNOWN> {
38 [label="Postponed exit from lambda"];
39 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"];
40 [label="Jump: ^foo R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=UNKNOWN> {
R|<local>/a|.R|kotlin/String.length|
^ when () {
(R|<local>/b| is R|kotlin/String|) -> {
@@ -177,39 +179,38 @@ digraph localClassesWithImplicit_kt {
}
)"];
40 [label="Stub" style="filled" fillcolor=gray];
41 [label="Exit block" style="filled" fillcolor=gray];
41 [label="Stub" style="filled" fillcolor=gray];
42 [label="Exit block" style="filled" fillcolor=gray];
}
42 [label="Exit function foo" style="filled" fillcolor=red];
43 [label="Exit function foo" style="filled" fillcolor=red];
}
34 -> {35};
35 -> {36};
36 -> {43};
36 -> {37} [color=red];
36 -> {43} [style=dashed];
37 -> {38};
36 -> {37};
37 -> {44};
37 -> {38} [color=red];
37 -> {44} [style=dashed];
38 -> {39};
39 -> {42};
39 -> {40} [style=dotted];
39 -> {40};
40 -> {43};
40 -> {41} [style=dotted];
41 -> {42} [style=dotted];
43 -> {68 44};
44 -> {45};
42 -> {43} [style=dotted];
44 -> {69 45};
45 -> {46};
46 -> {47};
47 -> {48};
48 -> {49};
49 -> {50};
50 -> {51};
51 -> {59 52};
52 -> {53};
51 -> {52};
52 -> {60 53};
53 -> {54};
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {58};
58 -> {66};
59 -> {60};
58 -> {59};
59 -> {67};
60 -> {61};
61 -> {62};
62 -> {63};
@@ -218,153 +219,154 @@ digraph localClassesWithImplicit_kt {
65 -> {66};
66 -> {67};
67 -> {68};
68 -> {37} [color=green];
68 -> {43} [color=green style=dashed];
68 -> {69};
69 -> {38} [color=green];
69 -> {44} [color=green style=dashed];
subgraph cluster_19 {
color=red
69 [label="Enter function bar" style="filled" fillcolor=red];
70 [label="Enter function bar" style="filled" fillcolor=red];
subgraph cluster_20 {
color=blue
70 [label="Enter block"];
71 [label="Postponed enter to lambda"];
71 [label="Enter block"];
72 [label="Postponed enter to lambda"];
subgraph cluster_21 {
color=blue
78 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
79 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_22 {
color=blue
79 [label="Enter block"];
80 [label="Access variable R|<local>/b|"];
81 [label="Access variable <Unresolved name: length>#"];
82 [label="Access variable R|<local>/a|"];
83 [label="Access variable R|kotlin/String.length|"];
84 [label="Function call: this@R|/A|.R|<local>/baz|()"];
85 [label="Exit block"];
80 [label="Enter block"];
81 [label="Access variable R|<local>/b|"];
82 [label="Access variable <Unresolved name: length>#"];
83 [label="Access variable R|<local>/a|"];
84 [label="Access variable R|kotlin/String.length|"];
85 [label="Function call: this@R|/A|.R|<local>/baz|()"];
86 [label="Exit block"];
}
86 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
87 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
72 [label="Postponed exit from lambda"];
73 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"];
74 [label="Jump: ^bar R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=UNKNOWN> {
73 [label="Postponed exit from lambda"];
74 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"];
75 [label="Jump: ^bar R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=UNKNOWN> {
R|<local>/b|.<Unresolved name: length>#
R|<local>/a|.R|kotlin/String.length|
^ this@R|/A|.R|<local>/baz|()
}
)"];
75 [label="Stub" style="filled" fillcolor=gray];
76 [label="Exit block" style="filled" fillcolor=gray];
76 [label="Stub" style="filled" fillcolor=gray];
77 [label="Exit block" style="filled" fillcolor=gray];
}
77 [label="Exit function bar" style="filled" fillcolor=red];
78 [label="Exit function bar" style="filled" fillcolor=red];
}
69 -> {70};
70 -> {71};
71 -> {78};
71 -> {72} [color=red];
71 -> {78} [style=dashed];
72 -> {73};
71 -> {72};
72 -> {79};
72 -> {73} [color=red];
72 -> {79} [style=dashed];
73 -> {74};
74 -> {77};
74 -> {75} [style=dotted];
74 -> {75};
75 -> {78};
75 -> {76} [style=dotted];
76 -> {77} [style=dotted];
78 -> {86 79};
79 -> {80};
77 -> {78} [style=dotted];
79 -> {87 80};
80 -> {81};
81 -> {82};
82 -> {83};
83 -> {84};
84 -> {85};
85 -> {86};
86 -> {72} [color=green];
86 -> {78} [color=green style=dashed];
86 -> {87};
87 -> {73} [color=green];
87 -> {79} [color=green style=dashed];
subgraph cluster_23 {
color=red
87 [label="Enter function baz" style="filled" fillcolor=red];
88 [label="Enter function baz" style="filled" fillcolor=red];
subgraph cluster_24 {
color=blue
88 [label="Enter block"];
89 [label="Const: Int(1)"];
90 [label="Jump: ^baz Int(1)"];
91 [label="Stub" style="filled" fillcolor=gray];
92 [label="Exit block" style="filled" fillcolor=gray];
89 [label="Enter block"];
90 [label="Const: Int(1)"];
91 [label="Jump: ^baz Int(1)"];
92 [label="Stub" style="filled" fillcolor=gray];
93 [label="Exit block" style="filled" fillcolor=gray];
}
93 [label="Exit function baz" style="filled" fillcolor=red];
94 [label="Exit function baz" style="filled" fillcolor=red];
}
87 -> {88};
88 -> {89};
89 -> {90};
90 -> {93};
90 -> {91} [style=dotted];
90 -> {91};
91 -> {94};
91 -> {92} [style=dotted];
92 -> {93} [style=dotted];
93 -> {94} [style=dotted];
subgraph cluster_25 {
color=red
94 [label="Enter function <init>" style="filled" fillcolor=red];
95 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
96 [label="Exit function <init>" style="filled" fillcolor=red];
95 [label="Enter function <init>" style="filled" fillcolor=red];
96 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
97 [label="Exit function <init>" style="filled" fillcolor=red];
}
94 -> {95};
95 -> {96};
96 -> {97};
subgraph cluster_26 {
color=red
97 [label="Enter function foo" style="filled" fillcolor=red];
98 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_27 {
color=blue
98 [label="Enter block"];
99 [label="Postponed enter to lambda"];
99 [label="Enter block"];
100 [label="Postponed enter to lambda"];
subgraph cluster_28 {
color=blue
106 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
107 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_29 {
color=blue
107 [label="Enter block"];
108 [label="Access variable R|<local>/a|"];
109 [label="Access variable R|kotlin/String.length|"];
108 [label="Enter block"];
109 [label="Access variable R|<local>/a|"];
110 [label="Access variable R|kotlin/String.length|"];
subgraph cluster_30 {
color=blue
110 [label="Enter when"];
111 [label="Enter when"];
subgraph cluster_31 {
color=blue
111 [label="Enter when branch condition "];
112 [label="Access variable R|<local>/b|"];
113 [label="Type operator: (R|<local>/b| is R|kotlin/String|)"];
114 [label="Exit when branch condition"];
112 [label="Enter when branch condition "];
113 [label="Access variable R|<local>/b|"];
114 [label="Type operator: (R|<local>/b| is R|kotlin/String|)"];
115 [label="Exit when branch condition"];
}
subgraph cluster_32 {
color=blue
115 [label="Enter when branch condition else"];
116 [label="Exit when branch condition"];
116 [label="Enter when branch condition else"];
117 [label="Exit when branch condition"];
}
117 [label="Enter when branch result"];
118 [label="Enter when branch result"];
subgraph cluster_33 {
color=blue
118 [label="Enter block"];
119 [label="Const: Int(1)"];
120 [label="Exit block"];
119 [label="Enter block"];
120 [label="Const: Int(1)"];
121 [label="Exit block"];
}
121 [label="Exit when branch result"];
122 [label="Enter when branch result"];
122 [label="Exit when branch result"];
123 [label="Enter when branch result"];
subgraph cluster_34 {
color=blue
123 [label="Enter block"];
124 [label="Access variable R|<local>/b|"];
125 [label="Access variable R|kotlin/String.length|"];
126 [label="Function call: this@R|/<anonymous>|.R|/<anonymous>.bar|()"];
127 [label="Exit block"];
124 [label="Enter block"];
125 [label="Access variable R|<local>/b|"];
126 [label="Access variable R|kotlin/String.length|"];
127 [label="Function call: this@R|/<anonymous>|.R|/<anonymous>.bar|()"];
128 [label="Exit block"];
}
128 [label="Exit when branch result"];
129 [label="Exit when"];
129 [label="Exit when branch result"];
130 [label="Exit when"];
}
130 [label="Exit block"];
131 [label="Exit block"];
}
131 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
132 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
100 [label="Postponed exit from lambda"];
101 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"];
102 [label="Jump: ^foo R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=UNKNOWN> {
101 [label="Postponed exit from lambda"];
102 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"];
103 [label="Jump: ^foo R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=UNKNOWN> {
R|<local>/a|.R|kotlin/String.length|
^ when () {
(R|<local>/b| is R|kotlin/String|) -> {
@@ -378,39 +380,38 @@ digraph localClassesWithImplicit_kt {
}
)"];
103 [label="Stub" style="filled" fillcolor=gray];
104 [label="Exit block" style="filled" fillcolor=gray];
104 [label="Stub" style="filled" fillcolor=gray];
105 [label="Exit block" style="filled" fillcolor=gray];
}
105 [label="Exit function foo" style="filled" fillcolor=red];
106 [label="Exit function foo" style="filled" fillcolor=red];
}
97 -> {98};
98 -> {99};
99 -> {106};
99 -> {100} [color=red];
99 -> {106} [style=dashed];
100 -> {101};
99 -> {100};
100 -> {107};
100 -> {101} [color=red];
100 -> {107} [style=dashed];
101 -> {102};
102 -> {105};
102 -> {103} [style=dotted];
102 -> {103};
103 -> {106};
103 -> {104} [style=dotted];
104 -> {105} [style=dotted];
106 -> {131 107};
107 -> {108};
105 -> {106} [style=dotted];
107 -> {132 108};
108 -> {109};
109 -> {110};
110 -> {111};
111 -> {112};
112 -> {113};
113 -> {114};
114 -> {122 115};
115 -> {116};
114 -> {115};
115 -> {123 116};
116 -> {117};
117 -> {118};
118 -> {119};
119 -> {120};
120 -> {121};
121 -> {129};
122 -> {123};
121 -> {122};
122 -> {130};
123 -> {124};
124 -> {125};
125 -> {126};
@@ -419,85 +420,86 @@ digraph localClassesWithImplicit_kt {
128 -> {129};
129 -> {130};
130 -> {131};
131 -> {100} [color=green];
131 -> {106} [color=green style=dashed];
131 -> {132};
132 -> {101} [color=green];
132 -> {107} [color=green style=dashed];
subgraph cluster_35 {
color=red
132 [label="Enter function bar" style="filled" fillcolor=red];
133 [label="Enter function bar" style="filled" fillcolor=red];
subgraph cluster_36 {
color=blue
133 [label="Enter block"];
134 [label="Postponed enter to lambda"];
134 [label="Enter block"];
135 [label="Postponed enter to lambda"];
subgraph cluster_37 {
color=blue
141 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
142 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_38 {
color=blue
142 [label="Enter block"];
143 [label="Access variable R|<local>/a|"];
144 [label="Access variable R|kotlin/String.length|"];
145 [label="Access variable R|<local>/b|"];
146 [label="Access variable <Unresolved name: length>#"];
147 [label="Function call: this@R|/<anonymous>|.R|/<anonymous>.baz|()"];
148 [label="Exit block"];
143 [label="Enter block"];
144 [label="Access variable R|<local>/a|"];
145 [label="Access variable R|kotlin/String.length|"];
146 [label="Access variable R|<local>/b|"];
147 [label="Access variable <Unresolved name: length>#"];
148 [label="Function call: this@R|/<anonymous>|.R|/<anonymous>.baz|()"];
149 [label="Exit block"];
}
149 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
150 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
135 [label="Postponed exit from lambda"];
136 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"];
137 [label="Jump: ^bar R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=UNKNOWN> {
136 [label="Postponed exit from lambda"];
137 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"];
138 [label="Jump: ^bar R|/myRun|<R|kotlin/Int|>(<L> = myRun@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=UNKNOWN> {
R|<local>/a|.R|kotlin/String.length|
R|<local>/b|.<Unresolved name: length>#
^ this@R|/<anonymous>|.R|/<anonymous>.baz|()
}
)"];
138 [label="Stub" style="filled" fillcolor=gray];
139 [label="Exit block" style="filled" fillcolor=gray];
139 [label="Stub" style="filled" fillcolor=gray];
140 [label="Exit block" style="filled" fillcolor=gray];
}
140 [label="Exit function bar" style="filled" fillcolor=red];
141 [label="Exit function bar" style="filled" fillcolor=red];
}
132 -> {133};
133 -> {134};
134 -> {141};
134 -> {135} [color=red];
134 -> {141} [style=dashed];
135 -> {136};
134 -> {135};
135 -> {142};
135 -> {136} [color=red];
135 -> {142} [style=dashed];
136 -> {137};
137 -> {140};
137 -> {138} [style=dotted];
137 -> {138};
138 -> {141};
138 -> {139} [style=dotted];
139 -> {140} [style=dotted];
141 -> {149 142};
142 -> {143};
140 -> {141} [style=dotted];
142 -> {150 143};
143 -> {144};
144 -> {145};
145 -> {146};
146 -> {147};
147 -> {148};
148 -> {149};
149 -> {135} [color=green];
149 -> {141} [color=green style=dashed];
149 -> {150};
150 -> {136} [color=green];
150 -> {142} [color=green style=dashed];
subgraph cluster_39 {
color=red
150 [label="Enter function baz" style="filled" fillcolor=red];
151 [label="Enter function baz" style="filled" fillcolor=red];
subgraph cluster_40 {
color=blue
151 [label="Enter block"];
152 [label="Const: Int(1)"];
153 [label="Jump: ^baz Int(1)"];
154 [label="Stub" style="filled" fillcolor=gray];
155 [label="Exit block" style="filled" fillcolor=gray];
152 [label="Enter block"];
153 [label="Const: Int(1)"];
154 [label="Jump: ^baz Int(1)"];
155 [label="Stub" style="filled" fillcolor=gray];
156 [label="Exit block" style="filled" fillcolor=gray];
}
156 [label="Exit function baz" style="filled" fillcolor=red];
157 [label="Exit function baz" style="filled" fillcolor=red];
}
150 -> {151};
151 -> {152};
152 -> {153};
153 -> {156};
153 -> {154} [style=dotted];
153 -> {154};
154 -> {157};
154 -> {155} [style=dotted];
155 -> {156} [style=dotted];
156 -> {157} [style=dotted];
}
@@ -10,92 +10,94 @@ digraph inAnonymousObject_kt {
color=blue
1 [label="Enter block"];
2 [label="Exit anonymous object"];
3 [label="Variable declaration: lval obj: R|<anonymous>|"];
4 [label="Access variable R|<local>/obj|"];
5 [label="Function call: R|<local>/obj|.R|/<anonymous>.run|()"];
6 [label="Function call: R|<local>/d|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
7 [label="Exit block"];
3 [label="Exit anonymous object expression"];
4 [label="Variable declaration: lval obj: R|<anonymous>|"];
5 [label="Access variable R|<local>/obj|"];
6 [label="Function call: R|<local>/obj|.R|/<anonymous>.run|()"];
7 [label="Function call: R|<local>/d|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
8 [label="Exit block"];
}
8 [label="Exit function foo" style="filled" fillcolor=red];
9 [label="Exit function foo" style="filled" fillcolor=red];
}
subgraph cluster_2 {
color=blue
9 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
10 [label="Part of class initialization"];
10 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
11 [label="Part of class initialization"];
12 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
12 [label="Part of class initialization"];
13 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
1 -> {13 16 19 25} [color=red];
1 -> {14 17 20 26} [color=red];
2 -> {3};
2 -> {13 25 9} [color=green];
2 -> {13 25 9} [style=dashed];
2 -> {14 26 10} [color=green];
2 -> {14 26 10} [style=dashed];
3 -> {4};
4 -> {5};
5 -> {6};
6 -> {7};
7 -> {8};
9 -> {10} [color=green];
10 -> {11} [style=dotted];
10 -> {16} [color=green];
10 -> {16} [style=dashed];
8 -> {9};
10 -> {11} [color=green];
11 -> {12} [style=dotted];
11 -> {19} [color=green];
11 -> {19} [style=dashed];
11 -> {17} [color=green];
11 -> {17} [style=dashed];
12 -> {13} [style=dotted];
12 -> {20} [color=green];
12 -> {20} [style=dashed];
subgraph cluster_3 {
color=red
13 [label="Enter function <init>" style="filled" fillcolor=red];
14 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
15 [label="Exit function <init>" style="filled" fillcolor=red];
14 [label="Enter function <init>" style="filled" fillcolor=red];
15 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
16 [label="Exit function <init>" style="filled" fillcolor=red];
}
13 -> {14};
14 -> {15};
15 -> {16};
subgraph cluster_4 {
color=red
16 [label="Enter property" style="filled" fillcolor=red];
17 [label="Access variable R|<local>/a|"];
18 [label="Exit property" style="filled" fillcolor=red];
17 [label="Enter property" style="filled" fillcolor=red];
18 [label="Access variable R|<local>/a|"];
19 [label="Exit property" style="filled" fillcolor=red];
}
16 -> {17};
17 -> {18};
18 -> {11} [color=green];
18 -> {19};
19 -> {12} [color=green];
subgraph cluster_5 {
color=red
19 [label="Enter init block" style="filled" fillcolor=red];
20 [label="Enter init block" style="filled" fillcolor=red];
subgraph cluster_6 {
color=blue
20 [label="Enter block"];
21 [label="Access variable R|<local>/b|"];
22 [label="Assignment: R|/<anonymous>.leaked|"];
23 [label="Exit block"];
21 [label="Enter block"];
22 [label="Access variable R|<local>/b|"];
23 [label="Assignment: R|/<anonymous>.leaked|"];
24 [label="Exit block"];
}
24 [label="Exit init block" style="filled" fillcolor=red];
25 [label="Exit init block" style="filled" fillcolor=red];
}
19 -> {20};
20 -> {21};
21 -> {22};
22 -> {23};
23 -> {24};
24 -> {12} [color=green];
24 -> {25};
25 -> {13} [color=green];
subgraph cluster_7 {
color=red
25 [label="Enter function run" style="filled" fillcolor=red];
26 [label="Enter function run" style="filled" fillcolor=red];
subgraph cluster_8 {
color=blue
26 [label="Enter block"];
27 [label="Function call: R|<local>/c|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
28 [label="Exit block"];
27 [label="Enter block"];
28 [label="Function call: R|<local>/c|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
29 [label="Exit block"];
}
29 [label="Exit function run" style="filled" fillcolor=red];
30 [label="Exit function run" style="filled" fillcolor=red];
}
25 -> {26};
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30};
}
@@ -80,8 +80,8 @@ digraph delegateWithAnonymousObject_kt {
}
22 -> {23} [color=green];
23 -> {24} [style=dotted];
23 -> {71} [color=green];
23 -> {71} [style=dashed];
23 -> {72} [color=green];
23 -> {72} [style=dashed];
subgraph cluster_9 {
color=red
@@ -94,115 +94,115 @@ digraph delegateWithAnonymousObject_kt {
subgraph cluster_10 {
color=red
35 [label="Enter function <init>" style="filled" fillcolor=red];
36 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
37 [label="Exit function <init>" style="filled" fillcolor=red];
36 [label="Enter function <init>" style="filled" fillcolor=red];
37 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
38 [label="Exit function <init>" style="filled" fillcolor=red];
}
35 -> {36};
36 -> {37};
37 -> {38};
subgraph cluster_11 {
color=red
38 [label="Enter function getValue" style="filled" fillcolor=red];
39 [label="Enter function getValue" style="filled" fillcolor=red];
subgraph cluster_12 {
color=blue
39 [label="Enter block"];
40 [label="Function call: R|/IssueListView.IssueListView|()"];
41 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"];
42 [label="Stub" style="filled" fillcolor=gray];
43 [label="Exit block" style="filled" fillcolor=gray];
40 [label="Enter block"];
41 [label="Function call: R|/IssueListView.IssueListView|()"];
42 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"];
43 [label="Stub" style="filled" fillcolor=gray];
44 [label="Exit block" style="filled" fillcolor=gray];
}
44 [label="Exit function getValue" style="filled" fillcolor=red];
45 [label="Exit function getValue" style="filled" fillcolor=red];
}
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {44};
41 -> {42} [style=dotted];
41 -> {42};
42 -> {45};
42 -> {43} [style=dotted];
43 -> {44} [style=dotted];
44 -> {45} [style=dotted];
subgraph cluster_13 {
color=red
45 [label="Enter function setValue" style="filled" fillcolor=red];
46 [label="Enter function setValue" style="filled" fillcolor=red];
subgraph cluster_14 {
color=blue
46 [label="Enter block"];
47 [label="Function call: R|/IssueListView.IssueListView|()"];
48 [label="Access variable R|<local>/value|"];
49 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)"];
50 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|<local>/value|)"];
51 [label="Stub" style="filled" fillcolor=gray];
52 [label="Exit block" style="filled" fillcolor=gray];
47 [label="Enter block"];
48 [label="Function call: R|/IssueListView.IssueListView|()"];
49 [label="Access variable R|<local>/value|"];
50 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)"];
51 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|<local>/value|)"];
52 [label="Stub" style="filled" fillcolor=gray];
53 [label="Exit block" style="filled" fillcolor=gray];
}
53 [label="Exit function setValue" style="filled" fillcolor=red];
54 [label="Exit function setValue" style="filled" fillcolor=red];
}
45 -> {46};
46 -> {47};
47 -> {48};
48 -> {49};
49 -> {50};
50 -> {53};
50 -> {51} [style=dotted];
50 -> {51};
51 -> {54};
51 -> {52} [style=dotted];
52 -> {53} [style=dotted];
53 -> {54} [style=dotted];
subgraph cluster_15 {
color=red
54 [label="Enter function getter" style="filled" fillcolor=red];
55 [label="Enter function getter" style="filled" fillcolor=red];
subgraph cluster_16 {
color=blue
55 [label="Enter block"];
56 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
57 [label="Access variable this@R|/IssuesListUserProfile|"];
58 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|IssueListView|>|(...)"];
59 [label="Jump: ^ this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|IssueListView|>|(this@R|/IssuesListUserProfile|, ::R|/IssuesListUserProfile.issueListView|)"];
60 [label="Stub" style="filled" fillcolor=gray];
61 [label="Exit block" style="filled" fillcolor=gray];
56 [label="Enter block"];
57 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
58 [label="Access variable this@R|/IssuesListUserProfile|"];
59 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|IssueListView|>|(...)"];
60 [label="Jump: ^ this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.getValue: R|IssueListView|>|(this@R|/IssuesListUserProfile|, ::R|/IssuesListUserProfile.issueListView|)"];
61 [label="Stub" style="filled" fillcolor=gray];
62 [label="Exit block" style="filled" fillcolor=gray];
}
62 [label="Exit function getter" style="filled" fillcolor=red];
63 [label="Exit function getter" style="filled" fillcolor=red];
}
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {58};
58 -> {59};
59 -> {62};
59 -> {60} [style=dotted];
59 -> {60};
60 -> {63};
60 -> {61} [style=dotted];
61 -> {62} [style=dotted];
62 -> {63} [style=dotted];
subgraph cluster_17 {
color=red
63 [label="Enter function setter" style="filled" fillcolor=red];
64 [label="Enter function setter" style="filled" fillcolor=red];
subgraph cluster_18 {
color=blue
64 [label="Enter block"];
65 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
66 [label="Access variable this@R|/IssuesListUserProfile|"];
67 [label="Access variable R|<local>/issueListView|"];
68 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(...)"];
69 [label="Exit block"];
65 [label="Enter block"];
66 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
67 [label="Access variable this@R|/IssuesListUserProfile|"];
68 [label="Access variable R|<local>/issueListView|"];
69 [label="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(...)"];
70 [label="Exit block"];
}
70 [label="Exit function setter" style="filled" fillcolor=red];
71 [label="Exit function setter" style="filled" fillcolor=red];
}
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {67};
67 -> {68};
68 -> {69};
69 -> {70};
70 -> {71};
subgraph cluster_19 {
color=red
71 [label="Enter property" style="filled" fillcolor=red];
72 [label="Postponed enter to lambda"];
73 [label="Postponed exit from lambda"];
74 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)"];
75 [label="Access variable this@R|/IssuesListUserProfile|"];
76 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...).<Unresolved name: provideDelegate>#(...)"];
77 [label="Postponed enter to lambda"];
72 [label="Enter property" style="filled" fillcolor=red];
73 [label="Postponed enter to lambda"];
74 [label="Postponed exit from lambda"];
75 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)"];
76 [label="Access variable this@R|/IssuesListUserProfile|"];
77 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...).<Unresolved name: provideDelegate>#(...)"];
78 [label="Postponed enter to lambda"];
subgraph cluster_20 {
color=blue
28 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
@@ -210,38 +210,40 @@ digraph delegateWithAnonymousObject_kt {
color=blue
29 [label="Enter block"];
30 [label="Exit anonymous object"];
31 [label="Exit block"];
31 [label="Exit anonymous object expression"];
32 [label="Exit block"];
}
32 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
33 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
subgraph cluster_22 {
color=blue
33 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
34 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
34 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
35 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
}
78 [label="Postponed exit from lambda"];
79 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)"];
80 [label="Exit property" style="filled" fillcolor=red];
79 [label="Postponed exit from lambda"];
80 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)"];
81 [label="Exit property" style="filled" fillcolor=red];
}
71 -> {72};
72 -> {73};
72 -> {} [style=dashed];
73 -> {74};
73 -> {} [style=dashed];
74 -> {75};
75 -> {76};
76 -> {77};
77 -> {78 28};
77 -> {28} [style=dashed];
78 -> {79};
77 -> {78};
78 -> {79 28};
78 -> {28} [style=dashed];
79 -> {80};
80 -> {24} [color=green];
80 -> {81};
81 -> {24} [color=green];
28 -> {29};
29 -> {30};
29 -> {35 38 45} [color=red];
29 -> {36 39 46} [color=red];
30 -> {31};
30 -> {35 38 45 33} [color=green];
30 -> {35 38 45 33} [style=dashed];
30 -> {36 39 46 34} [color=green];
30 -> {36 39 46 34} [style=dashed];
31 -> {32};
33 -> {34} [color=green];
32 -> {33};
34 -> {35} [color=green];
}
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.DiagnosticReporter
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.expressions.FirAnonymousObjectExpression
import org.jetbrains.kotlin.fir.resolve.symbolProvider
import org.jetbrains.kotlin.fir.types.classId
import org.jetbrains.kotlin.fir.types.coneType
@@ -26,8 +27,8 @@ object FirSealedSupertypeChecker : FirMemberDeclarationChecker() {
checkGlobalDeclaration(declaration, context, reporter)
}
} else if (declaration is FirProperty) {
val initializer = declaration.initializer.safeAs<FirClass<*>>() ?: return
checkLocalDeclaration(initializer, context, reporter)
val initializer = declaration.initializer as? FirAnonymousObjectExpression ?: return
checkLocalDeclaration(initializer.anonymousObject, context, reporter)
}
}
@@ -77,6 +77,10 @@ abstract class AbstractDiagnosticCollectorVisitor(
}
}
override fun visitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression, data: Nothing?) {
anonymousObjectExpression.anonymousObject.accept(this, data)
}
override fun visitAnonymousObject(anonymousObject: FirAnonymousObject, data: Nothing?) {
withSuppressedDiagnostics(anonymousObject) {
visitClassAndChildren(anonymousObject, anonymousObject.defaultType())
@@ -1512,7 +1512,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
is FirGetClassCall -> generate(expression)
is FirContinueExpression -> generate(expression)
is FirBreakExpression -> generate(expression)
is FirAnonymousObject -> generate(expression)
is FirAnonymousObjectExpression -> generate(expression.anonymousObject)
is FirUnitExpression -> generate(expression)
is FirStringConcatenationCall -> generate(expression)
is FirAnonymousFunction -> generate(expression, isStatement = false)
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.descriptors.Visibilities
import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.expressions.FirAnonymousObjectExpression
import org.jetbrains.kotlin.fir.lazy.Fir2IrLazyClass
import org.jetbrains.kotlin.fir.resolve.firProvider
import org.jetbrains.kotlin.fir.resolve.symbolProvider
@@ -368,7 +369,7 @@ class Fir2IrClassifierStorage(
}
fun putEnumEntryClassInScope(enumEntry: FirEnumEntry, correspondingClass: IrClass) {
localStorage.putLocalClass(enumEntry.initializer as FirAnonymousObject, correspondingClass)
localStorage.putLocalClass((enumEntry.initializer as FirAnonymousObjectExpression).anonymousObject, correspondingClass)
}
internal fun getCachedIrEnumEntry(enumEntry: FirEnumEntry): IrEnumEntry? = enumEntryCache[enumEntry]
@@ -396,10 +397,10 @@ class Fir2IrClassifierStorage(
this.parent = irParent
}
val initializer = enumEntry.initializer
if (initializer is FirAnonymousObject) {
if (initializer is FirAnonymousObjectExpression) {
// An enum entry with its own members
if (initializer.declarations.any { it !is FirConstructor }) {
val klass = getIrAnonymousObjectForEnumEntry(initializer, enumEntry.name, irParent)
if (initializer.anonymousObject.declarations.any { it !is FirConstructor }) {
val klass = getIrAnonymousObjectForEnumEntry(initializer.anonymousObject, enumEntry.name, irParent)
this.correspondingClass = klass
}
// Otherwise, this is a default-ish enum entry whose initializer would be a delegating constructor call,
@@ -44,7 +44,7 @@ class Fir2IrImplicitCastInserter(
override fun visitAnnotationCall(annotationCall: FirAnnotationCall, data: IrElement): IrElement = data
override fun visitAnonymousObject(anonymousObject: FirAnonymousObject, data: IrElement): IrElement = data
override fun visitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression, data: IrElement): IrElement = data
override fun visitAnonymousFunction(anonymousFunction: FirAnonymousFunction, data: IrElement): IrElement = data
@@ -106,7 +106,7 @@ class Fir2IrVisitor(
if (correspondingClass != null) {
declarationStorage.enterScope(irEnumEntry)
classifierStorage.putEnumEntryClassInScope(enumEntry, correspondingClass)
val anonymousObject = enumEntry.initializer as FirAnonymousObject
val anonymousObject = (enumEntry.initializer as FirAnonymousObjectExpression).anonymousObject
converter.processAnonymousObjectMembers(anonymousObject, correspondingClass)
conversionScope.withParent(correspondingClass) {
conversionScope.withContainingFirClass(anonymousObject) {
@@ -123,10 +123,10 @@ class Fir2IrVisitor(
)
}
declarationStorage.leaveScope(irEnumEntry)
} else if (initializer is FirAnonymousObject) {
} else if (initializer is FirAnonymousObjectExpression) {
// Otherwise, this is a default-ish enum entry, which doesn't need its own synthetic class.
// During raw FIR building, we put the delegated constructor call inside an anonymous object.
val delegatedConstructor = initializer.primaryConstructor?.delegatedConstructor
val delegatedConstructor = initializer.anonymousObject.primaryConstructor?.delegatedConstructor
if (delegatedConstructor != null) {
with(memberGenerator) {
irEnumEntry.initializerExpression = irFactory.createExpressionBody(
@@ -159,6 +159,10 @@ class Fir2IrVisitor(
}
}
override fun visitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression, data: Any?): IrElement {
return visitAnonymousObject(anonymousObjectExpression.anonymousObject, data)
}
override fun visitAnonymousObject(anonymousObject: FirAnonymousObject, data: Any?): IrElement {
val irParent = conversionScope.parentFromStack()
// NB: for implicit types it is possible that anonymous object is already cached
@@ -546,72 +546,75 @@ class DeclarationsConverter(
*/
fun convertObjectLiteral(objectLiteral: LighterASTNode): FirElement {
return withChildClassName(ANONYMOUS_OBJECT_NAME) {
buildAnonymousObject {
buildAnonymousObjectExpression {
val objectDeclaration = objectLiteral.getChildNodesByType(OBJECT_DECLARATION).first()
source = objectDeclaration.toFirSourceElement()
origin = FirDeclarationOrigin.Source
moduleData = baseModuleData
classKind = ClassKind.OBJECT
scopeProvider = baseScopeProvider
symbol = FirAnonymousObjectSymbol()
context.applyToActualCapturedTypeParameters(false) {
typeParameters += buildOuterClassTypeParameterRef { this.symbol = it }
}
val delegatedSelfType = objectLiteral.toDelegatedSelfType(this)
registerSelfType(delegatedSelfType)
val sourceElement = objectDeclaration.toFirSourceElement()
source = sourceElement
anonymousObject = buildAnonymousObject {
source = objectDeclaration.toFirSourceElement()
origin = FirDeclarationOrigin.Source
moduleData = baseModuleData
classKind = ClassKind.OBJECT
scopeProvider = baseScopeProvider
symbol = FirAnonymousObjectSymbol()
context.applyToActualCapturedTypeParameters(false) {
typeParameters += buildOuterClassTypeParameterRef { this.symbol = it } }
val delegatedSelfType = objectLiteral.toDelegatedSelfType(this)
registerSelfType(delegatedSelfType)
var modifiers = Modifier()
var primaryConstructor: LighterASTNode? = null
val superTypeRefs = mutableListOf<FirTypeRef>()
val superTypeCallEntry = mutableListOf<FirExpression>()
var delegatedSuperTypeRef: FirTypeRef? = null
var classBody: LighterASTNode? = null
var delegatedConstructorSource: FirLightSourceElement? = null
var delegateFields: List<FirField>? = null
var modifiers = Modifier()
var primaryConstructor: LighterASTNode? = null
val superTypeRefs = mutableListOf<FirTypeRef>()
val superTypeCallEntry = mutableListOf<FirExpression>()
var delegatedSuperTypeRef: FirTypeRef? = null
var classBody: LighterASTNode? = null
var delegatedConstructorSource: FirLightSourceElement? = null
var delegateFields: List<FirField>? = null
objectDeclaration.forEachChildren {
when (it.tokenType) {
MODIFIER_LIST -> modifiers = convertModifierList(it)
PRIMARY_CONSTRUCTOR -> primaryConstructor = it
SUPER_TYPE_LIST -> convertDelegationSpecifiers(it).let { specifiers ->
delegatedSuperTypeRef = specifiers.delegatedSuperTypeRef
superTypeRefs += specifiers.superTypesRef
superTypeCallEntry += specifiers.delegatedConstructorArguments
delegatedConstructorSource = specifiers.delegatedConstructorSource
delegateFields = specifiers.delegateFields
objectDeclaration.forEachChildren {
when (it.tokenType) {
MODIFIER_LIST -> modifiers = convertModifierList(it)
PRIMARY_CONSTRUCTOR -> primaryConstructor = it
SUPER_TYPE_LIST -> convertDelegationSpecifiers(it).let { specifiers ->
delegatedSuperTypeRef = specifiers.delegatedSuperTypeRef
superTypeRefs += specifiers.superTypesRef
superTypeCallEntry += specifiers.delegatedConstructorArguments
delegatedConstructorSource = specifiers.delegatedConstructorSource
delegateFields = specifiers.delegateFields
}
CLASS_BODY -> classBody = it
}
CLASS_BODY -> classBody = it
}
}
superTypeRefs.ifEmpty {
superTypeRefs += implicitAnyType
delegatedSuperTypeRef = implicitAnyType
}
val delegatedSuperType = delegatedSuperTypeRef ?: buildImplicitTypeRef()
superTypeRefs.ifEmpty {
superTypeRefs += implicitAnyType
delegatedSuperTypeRef = implicitAnyType
}
val delegatedSuperType = delegatedSuperTypeRef ?: buildImplicitTypeRef()
annotations += modifiers.annotations
this.superTypeRefs += superTypeRefs
typeRef = delegatedSelfType
annotations += modifiers.annotations
this.superTypeRefs += superTypeRefs
this@buildAnonymousObjectExpression.typeRef = delegatedSelfType
val classWrapper = ClassWrapper(
SpecialNames.NO_NAME_PROVIDED, modifiers, ClassKind.OBJECT, this,
hasPrimaryConstructor = false,
hasSecondaryConstructor = classBody.getChildNodesByType(SECONDARY_CONSTRUCTOR).isNotEmpty(),
hasDefaultConstructor = false,
delegatedSelfTypeRef = delegatedSelfType,
delegatedSuperTypeRef = delegatedSuperType,
superTypeCallEntry = superTypeCallEntry
)
//parse primary constructor
convertPrimaryConstructor(
primaryConstructor, typeRef.source, classWrapper, delegatedConstructorSource
)?.let { this.declarations += it.firConstructor }
delegateFields?.let { this.declarations += it }
val classWrapper = ClassWrapper(
SpecialNames.NO_NAME_PROVIDED, modifiers, ClassKind.OBJECT, this,
hasPrimaryConstructor = false,
hasSecondaryConstructor = classBody.getChildNodesByType(SECONDARY_CONSTRUCTOR).isNotEmpty(),
hasDefaultConstructor = false,
delegatedSelfTypeRef = delegatedSelfType,
delegatedSuperTypeRef = delegatedSuperType,
superTypeCallEntry = superTypeCallEntry
)
//parse primary constructor
convertPrimaryConstructor(
primaryConstructor, delegatedSelfType.source, classWrapper, delegatedConstructorSource
)?.let { this.declarations += it.firConstructor }
delegateFields?.let { this.declarations += it }
//parse declarations
classBody?.let {
this.declarations += convertClassBody(it, classWrapper)
//parse declarations
classBody?.let {
this.declarations += convertClassBody(it, classWrapper)
}
}
}
}
@@ -659,41 +662,45 @@ class DeclarationsConverter(
}
annotations += modifiers.annotations
initializer = withChildClassName(enumEntryName) {
buildAnonymousObject {
source = enumEntry.toFirSourceElement(FirFakeSourceElementKind.EnumInitializer)
moduleData = baseModuleData
origin = FirDeclarationOrigin.Source
classKind = ClassKind.ENUM_ENTRY
scopeProvider = baseScopeProvider
symbol = FirAnonymousObjectSymbol()
annotations += modifiers.annotations
val enumClassWrapper = ClassWrapper(
enumEntryName, modifiers, ClassKind.ENUM_ENTRY, this,
hasPrimaryConstructor = true,
hasSecondaryConstructor = classBodyNode.getChildNodesByType(SECONDARY_CONSTRUCTOR).isNotEmpty(),
hasDefaultConstructor = false,
delegatedSelfTypeRef = buildResolvedTypeRef {
type = ConeClassLikeTypeImpl(
this@buildAnonymousObject.symbol.toLookupTag(),
emptyArray(),
isNullable = false
)
}.also { registerSelfType(it) },
delegatedSuperTypeRef = classWrapper.delegatedSelfTypeRef,
superTypeCallEntry = enumSuperTypeCallEntry
)
superTypeRefs += enumClassWrapper.delegatedSuperTypeRef
convertPrimaryConstructor(
null,
enumEntry.toFirSourceElement(),
enumClassWrapper,
superTypeCallEntry?.toFirSourceElement(),
isEnumEntry = true
)?.let { declarations += it.firConstructor }
classBodyNode?.also {
// Use ANONYMOUS_OBJECT_NAME for the owner class id of enum entry declarations
withChildClassName(ANONYMOUS_OBJECT_NAME, forceLocalContext = true) {
declarations += convertClassBody(it, enumClassWrapper)
buildAnonymousObjectExpression {
val entrySource = enumEntry.toFirSourceElement(FirFakeSourceElementKind.EnumInitializer)
source = entrySource
anonymousObject = buildAnonymousObject {
source = entrySource
moduleData = baseModuleData
origin = FirDeclarationOrigin.Source
classKind = ClassKind.ENUM_ENTRY
scopeProvider = baseScopeProvider
symbol = FirAnonymousObjectSymbol()
annotations += modifiers.annotations
val enumClassWrapper = ClassWrapper(
enumEntryName, modifiers, ClassKind.ENUM_ENTRY, this,
hasPrimaryConstructor = true,
hasSecondaryConstructor = classBodyNode.getChildNodesByType(SECONDARY_CONSTRUCTOR).isNotEmpty(),
hasDefaultConstructor = false,
delegatedSelfTypeRef = buildResolvedTypeRef {
type = ConeClassLikeTypeImpl(
this@buildAnonymousObject.symbol.toLookupTag(),
emptyArray(),
isNullable = false
)
}.also { registerSelfType(it) },
delegatedSuperTypeRef = classWrapper.delegatedSelfTypeRef,
superTypeCallEntry = enumSuperTypeCallEntry
)
superTypeRefs += enumClassWrapper.delegatedSuperTypeRef
convertPrimaryConstructor(
null,
enumEntry.toFirSourceElement(),
enumClassWrapper,
superTypeCallEntry?.toFirSourceElement(),
isEnumEntry = true
)?.let { declarations += it.firConstructor }
classBodyNode?.also {
// Use ANONYMOUS_OBJECT_NAME for the owner class id of enum entry declarations
withChildClassName(ANONYMOUS_OBJECT_NAME, forceLocalContext = true) {
declarations += convertClassBody(it, enumClassWrapper)
}
}
}
}
@@ -758,43 +758,48 @@ open class RawFirBuilder(
}
extractAnnotationsTo(this)
initializer = withChildClassName(nameAsSafeName) {
buildAnonymousObject {
source = toFirSourceElement(FirFakeSourceElementKind.EnumInitializer)
moduleData = baseModuleData
origin = FirDeclarationOrigin.Source
classKind = ClassKind.ENUM_ENTRY
scopeProvider = this@RawFirBuilder.baseScopeProvider
symbol = FirAnonymousObjectSymbol()
buildAnonymousObjectExpression {
val enumEntrySource = toFirSourceElement(FirFakeSourceElementKind.EnumInitializer)
source = enumEntrySource
anonymousObject = buildAnonymousObject {
source = enumEntrySource
moduleData = baseModuleData
origin = FirDeclarationOrigin.Source
classKind = ClassKind.ENUM_ENTRY
scopeProvider = this@RawFirBuilder.baseScopeProvider
symbol = FirAnonymousObjectSymbol()
extractAnnotationsTo(this)
val delegatedEntrySelfType = buildResolvedTypeRef {
type = ConeClassLikeTypeImpl(this@buildAnonymousObject.symbol.toLookupTag(), emptyArray(), isNullable = false)
}
registerSelfType(delegatedEntrySelfType)
extractAnnotationsTo(this)
val delegatedEntrySelfType = buildResolvedTypeRef {
type =
ConeClassLikeTypeImpl(this@buildAnonymousObject.symbol.toLookupTag(), emptyArray(), isNullable = false)
}
registerSelfType(delegatedEntrySelfType)
superTypeRefs += delegatedEnumSelfTypeRef
val superTypeCallEntry = superTypeListEntries.firstIsInstanceOrNull<KtSuperTypeCallEntry>()
val correctedEnumSelfTypeRef = buildResolvedTypeRef {
source = superTypeCallEntry?.calleeExpression?.typeReference?.toFirSourceElement()
type = delegatedEnumSelfTypeRef.type
}
declarations += primaryConstructor.toFirConstructor(
superTypeCallEntry,
correctedEnumSelfTypeRef,
delegatedEntrySelfType,
owner = ktEnumEntry,
typeParameters
)
// Use ANONYMOUS_OBJECT_NAME for the owner class id for enum entry declarations (see KT-42351)
withChildClassName(ANONYMOUS_OBJECT_NAME, forceLocalContext = true) {
for (declaration in ktEnumEntry.declarations) {
declarations += declaration.toFirDeclaration(
correctedEnumSelfTypeRef,
delegatedSelfType = delegatedEntrySelfType,
ktEnumEntry,
ownerClassBuilder = this,
ownerTypeParameters = emptyList()
)
superTypeRefs += delegatedEnumSelfTypeRef
val superTypeCallEntry = superTypeListEntries.firstIsInstanceOrNull<KtSuperTypeCallEntry>()
val correctedEnumSelfTypeRef = buildResolvedTypeRef {
source = superTypeCallEntry?.calleeExpression?.typeReference?.toFirSourceElement()
type = delegatedEnumSelfTypeRef.type
}
declarations += primaryConstructor.toFirConstructor(
superTypeCallEntry,
correctedEnumSelfTypeRef,
delegatedEntrySelfType,
owner = ktEnumEntry,
typeParameters
)
// Use ANONYMOUS_OBJECT_NAME for the owner class id for enum entry declarations (see KT-42351)
withChildClassName(ANONYMOUS_OBJECT_NAME, forceLocalContext = true) {
for (declaration in ktEnumEntry.declarations) {
declarations += declaration.toFirDeclaration(
correctedEnumSelfTypeRef,
delegatedSelfType = delegatedEntrySelfType,
ktEnumEntry,
ownerClassBuilder = this,
ownerTypeParameters = emptyList()
)
}
}
}
}
@@ -943,37 +948,39 @@ open class RawFirBuilder(
override fun visitObjectLiteralExpression(expression: KtObjectLiteralExpression, data: Unit): FirElement {
val objectDeclaration = expression.objectDeclaration
return withChildClassName(ANONYMOUS_OBJECT_NAME, forceLocalContext = true) {
buildAnonymousObject {
source = objectDeclaration.toFirSourceElement()
moduleData = baseModuleData
origin = FirDeclarationOrigin.Source
classKind = ClassKind.OBJECT
scopeProvider = baseScopeProvider
symbol = FirAnonymousObjectSymbol()
context.applyToActualCapturedTypeParameters(false) {
typeParameters += buildOuterClassTypeParameterRef { symbol = it }
}
val delegatedSelfType = objectDeclaration.toDelegatedSelfType(this)
registerSelfType(delegatedSelfType)
objectDeclaration.extractAnnotationsTo(this)
val delegatedSuperType = objectDeclaration.extractSuperTypeListEntriesTo(
this,
delegatedSelfType,
null,
ClassKind.CLASS,
containerTypeParameters = emptyList()
)
typeRef = delegatedSelfType
for (declaration in objectDeclaration.declarations) {
declarations += declaration.toFirDeclaration(
delegatedSuperType,
buildAnonymousObjectExpression {
val sourceElement = objectDeclaration.toFirSourceElement()
source = sourceElement
anonymousObject = buildAnonymousObject {
source = sourceElement
moduleData = baseModuleData
origin = FirDeclarationOrigin.Source
classKind = ClassKind.OBJECT
scopeProvider = baseScopeProvider
symbol = FirAnonymousObjectSymbol()
context.applyToActualCapturedTypeParameters(false) {
typeParameters += buildOuterClassTypeParameterRef { symbol = it } }
val delegatedSelfType = objectDeclaration.toDelegatedSelfType(this)
registerSelfType(delegatedSelfType)
objectDeclaration.extractAnnotationsTo(this)
val delegatedSuperType = objectDeclaration.extractSuperTypeListEntriesTo(
this,
delegatedSelfType,
owner = objectDeclaration,
ownerClassBuilder = this,
ownerTypeParameters = emptyList()
null,
ClassKind.CLASS,
containerTypeParameters = emptyList()
)
this@buildAnonymousObjectExpression.typeRef = delegatedSelfType
for (declaration in objectDeclaration.declarations) {
declarations += declaration.toFirDeclaration(
delegatedSuperType,
delegatedSelfType,
owner = objectDeclaration,
ownerClassBuilder = this,
ownerTypeParameters = emptyList()
)
}
}
}
}
@@ -118,9 +118,14 @@ fun FirRegularClass.defaultType(): ConeClassLikeTypeImpl {
}
fun FirAnonymousObject.defaultType(): ConeClassLikeType {
return this.typeRef.coneTypeSafe() ?: ConeClassLikeTypeImpl(
return ConeClassLikeTypeImpl(
symbol.toLookupTag(),
emptyArray(),
typeParameters.map {
ConeTypeParameterTypeImpl(
it.symbol.toLookupTag(),
isNullable = false
)
}.toTypedArray(),
isNullable = false
)
}
@@ -309,6 +309,10 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
return controlFlowGraph
}
fun exitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression) {
graphBuilder.exitAnonymousObjectExpression(anonymousObjectExpression).mergeIncomingFlow()
}
// ----------------------------------- Value parameters (and it's defaults) -----------------------------------
fun enterValueParameter(valueParameter: FirValueParameter) {
@@ -251,6 +251,12 @@ class AnonymousObjectExitNode(owner: ControlFlowGraph, override val fir: FirAnon
}
}
class AnonymousObjectExpressionExitNode(owner: ControlFlowGraph, override val fir: FirAnonymousObjectExpression, level: Int, id: Int) : CFGNode<FirAnonymousObjectExpression>(owner, level, id) {
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
return visitor.visitAnonymousObjectExpressionExitNode(this, data)
}
}
// ----------------------------------- Initialization -----------------------------------
class PartOfClassInitializationNode(owner: ControlFlowGraph, override val fir: FirControlFlowGraphOwner, level: Int, id: Int) : CFGNodeWithCfgOwner<FirControlFlowGraphOwner>(owner, level, id) {
@@ -108,6 +108,7 @@ fun CFGNode<*>.render(): String =
is ClassExitNode -> "Exit class ${owner.name}"
is LocalClassExitNode -> "Exit local class ${owner.name}"
is AnonymousObjectExitNode -> "Exit anonymous object"
is AnonymousObjectExpressionExitNode -> "Exit anonymous object expression"
is ContractDescriptionEnterNode -> "Enter contract description"
@@ -440,6 +440,12 @@ class ControlFlowGraphBuilder {
return node to graph
}
fun exitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression): AnonymousObjectExpressionExitNode {
return createAnonymousObjectExpressionExitNode(anonymousObjectExpression).also {
addNewSimpleNodeIfPossible(it)
}
}
fun visitLocalClassFunctions(klass: FirClass<*>, node: CFGNodeWithCfgOwner<*>) {
klass.declarations.filterIsInstance<FirFunction<*>>().forEach { function ->
val functionGraph = function.controlFlowGraphReference?.controlFlowGraph
@@ -224,6 +224,9 @@ fun ControlFlowGraphBuilder.createPostponedLambdaEnterNode(fir: FirAnonymousFunc
fun ControlFlowGraphBuilder.createAnonymousObjectExitNode(fir: FirAnonymousObject): AnonymousObjectExitNode =
AnonymousObjectExitNode(currentGraph, fir, levelCounter, createId())
fun ControlFlowGraphBuilder.createAnonymousObjectExpressionExitNode(fir: FirAnonymousObjectExpression): AnonymousObjectExpressionExitNode =
AnonymousObjectExpressionExitNode(currentGraph, fir, levelCounter, createId())
fun ControlFlowGraphBuilder.createUnionFunctionCallArgumentsNode(fir: FirElement): UnionFunctionCallArgumentsNode =
UnionFunctionCallArgumentsNode(currentGraph, fir, levelCounter, createId())
@@ -52,6 +52,10 @@ abstract class ControlFlowGraphVisitor<out R, in D> {
return visitNode(node, data)
}
open fun visitAnonymousObjectExpressionExitNode(node: AnonymousObjectExpressionExitNode, data: D): R {
return visitNode(node, data)
}
open fun visitClassEnterNode(node: ClassEnterNode, data: D): R {
return visitNode(node, data)
}
@@ -137,7 +137,7 @@ open class FirApplySupertypesTransformer(
override fun transformAnonymousObject(anonymousObject: FirAnonymousObject, data: Any?): FirStatement {
applyResolvedSupertypesToClass(anonymousObject)
return super.transformAnonymousObject(anonymousObject, data)
return anonymousObject.transformChildren(this, data) as FirAnonymousObject
}
private fun getResolvedSupertypeRefs(classLikeDeclaration: FirClassLikeDeclaration<*>): List<FirResolvedTypeRef> {
@@ -271,6 +271,13 @@ open class FirBodyResolveTransformer(
return declarationsTransformer.transformAnonymousObject(anonymousObject, data)
}
override fun transformAnonymousObjectExpression(
anonymousObjectExpression: FirAnonymousObjectExpression,
data: ResolutionMode
): FirStatement {
return expressionsTransformer.transformAnonymousObjectExpression(anonymousObjectExpression, data)
}
override fun transformSimpleFunction(
simpleFunction: FirSimpleFunction,
data: ResolutionMode
@@ -422,12 +422,6 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
)
}
dataFlowAnalyzer.enterClass()
if (anonymousObject.typeRef !is FirResolvedTypeRef) {
anonymousObject.resultType = buildResolvedTypeRef {
source = anonymousObject.source
this.type = anonymousObject.defaultType()
}
}
val result = context.withAnonymousObject(anonymousObject, components) {
transformDeclarationContent(anonymousObject, data) as FirAnonymousObject
}
@@ -1063,6 +1063,21 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
return stringConcatenationCall
}
override fun transformAnonymousObjectExpression(
anonymousObjectExpression: FirAnonymousObjectExpression,
data: ResolutionMode
): FirStatement {
anonymousObjectExpression.transformAnonymousObject(transformer, data)
if (anonymousObjectExpression.typeRef !is FirResolvedTypeRef) {
anonymousObjectExpression.resultType = buildResolvedTypeRef {
source = anonymousObjectExpression.source
this.type = anonymousObjectExpression.anonymousObject.defaultType()
}
}
dataFlowAnalyzer.exitAnonymousObjectExpression(anonymousObjectExpression)
return anonymousObjectExpression
}
// ------------------------------------------------------------------------------------------------
internal fun <T> storeTypeFromCallee(access: T) where T : FirQualifiedAccess, T : FirExpression {
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.FirModuleData
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirExpression
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol
@@ -22,7 +21,7 @@ import org.jetbrains.kotlin.fir.visitors.*
* DO NOT MODIFY IT MANUALLY
*/
abstract class FirAnonymousObject : FirClass<FirAnonymousObject>, FirControlFlowGraphOwner, FirExpression() {
abstract class FirAnonymousObject : FirClass<FirAnonymousObject>(), FirControlFlowGraphOwner {
abstract override val source: FirSourceElement?
abstract override val moduleData: FirModuleData
abstract override val resolvePhase: FirResolvePhase
@@ -35,7 +34,6 @@ abstract class FirAnonymousObject : FirClass<FirAnonymousObject>, FirControlFlow
abstract override val annotations: List<FirAnnotationCall>
abstract override val scopeProvider: FirScopeProvider
abstract override val controlFlowGraphReference: FirControlFlowGraphReference?
abstract override val typeRef: FirTypeRef
abstract override val symbol: FirAnonymousObjectSymbol
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitAnonymousObject(this, data)
@@ -50,8 +48,6 @@ abstract class FirAnonymousObject : FirClass<FirAnonymousObject>, FirControlFlow
abstract override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?)
abstract override fun replaceTypeRef(newTypeRef: FirTypeRef)
abstract override fun <D> transformTypeParameters(transformer: FirTransformer<D>, data: D): FirAnonymousObject
abstract override fun <D> transformSuperTypeRefs(transformer: FirTransformer<D>, data: D): FirAnonymousObject
@@ -21,19 +21,19 @@ import org.jetbrains.kotlin.fir.visitors.*
* DO NOT MODIFY IT MANUALLY
*/
sealed interface FirClass<F : FirClass<F>> : FirClassLikeDeclaration<F>, FirStatement, FirTypeParameterRefsOwner {
override val source: FirSourceElement?
override val moduleData: FirModuleData
override val resolvePhase: FirResolvePhase
override val origin: FirDeclarationOrigin
override val attributes: FirDeclarationAttributes
override val typeParameters: List<FirTypeParameterRef>
override val symbol: FirClassSymbol<F>
val classKind: ClassKind
val superTypeRefs: List<FirTypeRef>
val declarations: List<FirDeclaration>
override val annotations: List<FirAnnotationCall>
val scopeProvider: FirScopeProvider
sealed class FirClass<F : FirClass<F>> : FirClassLikeDeclaration<F>(), FirStatement, FirTypeParameterRefsOwner {
abstract override val source: FirSourceElement?
abstract override val moduleData: FirModuleData
abstract override val resolvePhase: FirResolvePhase
abstract override val origin: FirDeclarationOrigin
abstract override val attributes: FirDeclarationAttributes
abstract override val typeParameters: List<FirTypeParameterRef>
abstract override val symbol: FirClassSymbol<F>
abstract val classKind: ClassKind
abstract val superTypeRefs: List<FirTypeRef>
abstract val declarations: List<FirDeclaration>
abstract override val annotations: List<FirAnnotationCall>
abstract val scopeProvider: FirScopeProvider
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitClass(this, data)
@@ -41,15 +41,15 @@ sealed interface FirClass<F : FirClass<F>> : FirClassLikeDeclaration<F>, FirStat
override fun <E: FirElement, D> transform(transformer: FirTransformer<D>, data: D): E =
transformer.transformClass(this, data) as E
override fun replaceResolvePhase(newResolvePhase: FirResolvePhase)
abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase)
fun replaceSuperTypeRefs(newSuperTypeRefs: List<FirTypeRef>)
abstract fun replaceSuperTypeRefs(newSuperTypeRefs: List<FirTypeRef>)
override fun <D> transformTypeParameters(transformer: FirTransformer<D>, data: D): FirClass<F>
abstract override fun <D> transformTypeParameters(transformer: FirTransformer<D>, data: D): FirClass<F>
fun <D> transformSuperTypeRefs(transformer: FirTransformer<D>, data: D): FirClass<F>
abstract fun <D> transformSuperTypeRefs(transformer: FirTransformer<D>, data: D): FirClass<F>
fun <D> transformDeclarations(transformer: FirTransformer<D>, data: D): FirClass<F>
abstract fun <D> transformDeclarations(transformer: FirTransformer<D>, data: D): FirClass<F>
override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirClass<F>
abstract override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirClass<F>
}
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.declarations
import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.FirModuleData
import org.jetbrains.kotlin.fir.FirPureAbstractElement
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.FirSymbolOwner
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
@@ -19,14 +20,14 @@ import org.jetbrains.kotlin.fir.visitors.*
* DO NOT MODIFY IT MANUALLY
*/
sealed interface FirClassLikeDeclaration<F : FirClassLikeDeclaration<F>> : FirAnnotatedDeclaration, FirStatement, FirSymbolOwner<F> {
override val source: FirSourceElement?
override val moduleData: FirModuleData
override val resolvePhase: FirResolvePhase
override val origin: FirDeclarationOrigin
override val attributes: FirDeclarationAttributes
override val annotations: List<FirAnnotationCall>
override val symbol: FirClassLikeSymbol<F>
sealed class FirClassLikeDeclaration<F : FirClassLikeDeclaration<F>> : FirPureAbstractElement(), FirAnnotatedDeclaration, FirStatement, FirSymbolOwner<F> {
abstract override val source: FirSourceElement?
abstract override val moduleData: FirModuleData
abstract override val resolvePhase: FirResolvePhase
abstract override val origin: FirDeclarationOrigin
abstract override val attributes: FirDeclarationAttributes
abstract override val annotations: List<FirAnnotationCall>
abstract override val symbol: FirClassLikeSymbol<F>
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitClassLikeDeclaration(this, data)
@@ -34,7 +35,7 @@ sealed interface FirClassLikeDeclaration<F : FirClassLikeDeclaration<F>> : FirAn
override fun <E: FirElement, D> transform(transformer: FirTransformer<D>, data: D): E =
transformer.transformClassLikeDeclaration(this, data) as E
override fun replaceResolvePhase(newResolvePhase: FirResolvePhase)
abstract override fun replaceResolvePhase(newResolvePhase: FirResolvePhase)
override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirClassLikeDeclaration<F>
abstract override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirClassLikeDeclaration<F>
}
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.fir.declarations
import org.jetbrains.kotlin.descriptors.ClassKind
import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.FirModuleData
import org.jetbrains.kotlin.fir.FirPureAbstractElement
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
@@ -23,7 +22,7 @@ import org.jetbrains.kotlin.fir.visitors.*
* DO NOT MODIFY IT MANUALLY
*/
abstract class FirRegularClass : FirPureAbstractElement(), FirMemberDeclaration, FirTypeParameterRefsOwner, FirControlFlowGraphOwner, FirClass<FirRegularClass> {
abstract class FirRegularClass : FirMemberDeclaration, FirTypeParameterRefsOwner, FirControlFlowGraphOwner, FirClass<FirRegularClass>() {
abstract override val source: FirSourceElement?
abstract override val moduleData: FirModuleData
abstract override val resolvePhase: FirResolvePhase
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.fir.declarations
import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.FirModuleData
import org.jetbrains.kotlin.fir.FirPureAbstractElement
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol
@@ -20,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.*
* DO NOT MODIFY IT MANUALLY
*/
abstract class FirTypeAlias : FirPureAbstractElement(), FirClassLikeDeclaration<FirTypeAlias>, FirMemberDeclaration, FirTypeParametersOwner {
abstract class FirTypeAlias : FirClassLikeDeclaration<FirTypeAlias>(), FirMemberDeclaration, FirTypeParametersOwner {
abstract override val source: FirSourceElement?
abstract override val moduleData: FirModuleData
abstract override val resolvePhase: FirResolvePhase
@@ -21,12 +21,10 @@ import org.jetbrains.kotlin.fir.declarations.builder.FirClassBuilder
import org.jetbrains.kotlin.fir.declarations.builder.FirDeclarationBuilder
import org.jetbrains.kotlin.fir.declarations.impl.FirAnonymousObjectImpl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.builder.FirExpressionBuilder
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl
import org.jetbrains.kotlin.fir.visitors.*
/*
@@ -35,7 +33,7 @@ import org.jetbrains.kotlin.fir.visitors.*
*/
@FirBuilderDsl
class FirAnonymousObjectBuilder : FirDeclarationBuilder, FirClassBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder {
class FirAnonymousObjectBuilder : FirDeclarationBuilder, FirClassBuilder, FirAnnotationContainerBuilder {
override var source: FirSourceElement? = null
override lateinit var moduleData: FirModuleData
override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR
@@ -47,7 +45,6 @@ class FirAnonymousObjectBuilder : FirDeclarationBuilder, FirClassBuilder, FirAnn
override val declarations: MutableList<FirDeclaration> = mutableListOf()
override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
override lateinit var scopeProvider: FirScopeProvider
override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null)
lateinit var symbol: FirAnonymousObjectSymbol
override fun build(): FirAnonymousObject {
@@ -63,7 +60,6 @@ class FirAnonymousObjectBuilder : FirDeclarationBuilder, FirClassBuilder, FirAnn
declarations,
annotations,
scopeProvider,
typeRef,
symbol,
)
}
@@ -38,7 +38,6 @@ internal class FirAnonymousObjectImpl(
override val declarations: MutableList<FirDeclaration>,
override val annotations: MutableList<FirAnnotationCall>,
override val scopeProvider: FirScopeProvider,
override var typeRef: FirTypeRef,
override val symbol: FirAnonymousObjectSymbol,
) : FirAnonymousObject() {
override var controlFlowGraphReference: FirControlFlowGraphReference? = null
@@ -53,7 +52,6 @@ internal class FirAnonymousObjectImpl(
declarations.forEach { it.accept(visitor, data) }
annotations.forEach { it.accept(visitor, data) }
controlFlowGraphReference?.accept(visitor, data)
typeRef.accept(visitor, data)
}
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirAnonymousObjectImpl {
@@ -62,7 +60,6 @@ internal class FirAnonymousObjectImpl(
transformDeclarations(transformer, data)
transformAnnotations(transformer, data)
controlFlowGraphReference = controlFlowGraphReference?.transform(transformer, data)
typeRef = typeRef.transform(transformer, data)
return this
}
@@ -98,8 +95,4 @@ internal class FirAnonymousObjectImpl(
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {
controlFlowGraphReference = newControlFlowGraphReference
}
override fun replaceTypeRef(newTypeRef: FirTypeRef) {
typeRef = newTypeRef
}
}
@@ -0,0 +1,36 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.expressions
import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.visitors.*
/*
* This file was generated automatically
* DO NOT MODIFY IT MANUALLY
*/
abstract class FirAnonymousObjectExpression : FirExpression() {
abstract override val source: FirSourceElement?
abstract override val typeRef: FirTypeRef
abstract override val annotations: List<FirAnnotationCall>
abstract val anonymousObject: FirAnonymousObject
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitAnonymousObjectExpression(this, data)
@Suppress("UNCHECKED_CAST")
override fun <E: FirElement, D> transform(transformer: FirTransformer<D>, data: D): E =
transformer.transformAnonymousObjectExpression(this, data) as E
abstract override fun replaceTypeRef(newTypeRef: FirTypeRef)
abstract override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirAnonymousObjectExpression
abstract fun <D> transformAnonymousObject(transformer: FirTransformer<D>, data: D): FirAnonymousObjectExpression
}
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.fir.declarations.FirConstructor
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject
import org.jetbrains.kotlin.fir.expressions.FirAnonymousObjectExpression
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnosticHolder
import org.jetbrains.kotlin.fir.declarations.FirImport
import org.jetbrains.kotlin.fir.declarations.FirResolvedImport
@@ -302,6 +303,10 @@ abstract class FirTransformer<in D> : FirVisitor<FirElement, D>() {
return transformElement(anonymousObject, data)
}
open fun transformAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression, data: D): FirStatement {
return transformElement(anonymousObjectExpression, data)
}
open fun transformDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: D): FirDiagnosticHolder {
return transformElement(diagnosticHolder, data)
}
@@ -810,6 +815,10 @@ abstract class FirTransformer<in D> : FirVisitor<FirElement, D>() {
return transformAnonymousObject(anonymousObject, data)
}
final override fun visitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression, data: D): FirStatement {
return transformAnonymousObjectExpression(anonymousObjectExpression, data)
}
final override fun visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: D): FirDiagnosticHolder {
return transformDiagnosticHolder(diagnosticHolder, data)
}
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.fir.declarations.FirConstructor
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject
import org.jetbrains.kotlin.fir.expressions.FirAnonymousObjectExpression
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnosticHolder
import org.jetbrains.kotlin.fir.declarations.FirImport
import org.jetbrains.kotlin.fir.declarations.FirResolvedImport
@@ -221,6 +222,8 @@ abstract class FirVisitor<out R, in D> {
open fun visitAnonymousObject(anonymousObject: FirAnonymousObject, data: D): R = visitElement(anonymousObject, data)
open fun visitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression, data: D): R = visitElement(anonymousObjectExpression, data)
open fun visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: D): R = visitElement(diagnosticHolder, data)
open fun visitImport(import: FirImport, data: D): R = visitElement(import, data)
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.fir.declarations.FirConstructor
import org.jetbrains.kotlin.fir.declarations.FirFile
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject
import org.jetbrains.kotlin.fir.expressions.FirAnonymousObjectExpression
import org.jetbrains.kotlin.fir.diagnostics.FirDiagnosticHolder
import org.jetbrains.kotlin.fir.declarations.FirImport
import org.jetbrains.kotlin.fir.declarations.FirResolvedImport
@@ -301,6 +302,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
visitElement(anonymousObject)
}
open fun visitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression) {
visitElement(anonymousObjectExpression)
}
open fun visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder) {
visitElement(diagnosticHolder)
}
@@ -809,6 +814,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
visitAnonymousObject(anonymousObject)
}
final override fun visitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression, data: Nothing?) {
visitAnonymousObjectExpression(anonymousObjectExpression)
}
final override fun visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: Nothing?) {
visitDiagnosticHolder(diagnosticHolder)
}
@@ -479,6 +479,10 @@ class FirRenderer(builder: StringBuilder, private val mode: RenderMode = RenderM
}
}
override fun visitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression) {
anonymousObjectExpression.anonymousObject.accept(this)
}
override fun visitAnonymousObject(anonymousObject: FirAnonymousObject) {
anonymousObject.annotations.renderAnnotations()
print("object : ")
@@ -0,0 +1,45 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.expressions.builder
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirAnonymousObjectExpression
import org.jetbrains.kotlin.fir.expressions.impl.FirAnonymousObjectExpressionImpl
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl
import kotlin.contracts.ExperimentalContracts
import kotlin.contracts.contract
@FirBuilderDsl
class FirAnonymousObjectExpressionBuilder : FirAnnotationContainerBuilder, FirExpressionBuilder {
override var source: FirSourceElement? = null
override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null)
lateinit var anonymousObject: FirAnonymousObject
override val annotations: MutableList<FirAnnotationCall>
get() = error("Should not be called")
override fun build(): FirAnonymousObjectExpression {
return FirAnonymousObjectExpressionImpl(
source,
typeRef,
anonymousObject,
)
}
}
@OptIn(ExperimentalContracts::class)
inline fun buildAnonymousObjectExpression(init: FirAnonymousObjectExpressionBuilder.() -> Unit): FirAnonymousObjectExpression {
contract {
callsInPlace(init, kotlin.contracts.InvocationKind.EXACTLY_ONCE)
}
return FirAnonymousObjectExpressionBuilder().apply(init).build()
}
@@ -0,0 +1,51 @@
/*
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.fir.expressions.impl
import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirAnonymousObjectExpression
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.visitors.*
/*
* This file was generated automatically
* DO NOT MODIFY IT MANUALLY
*/
internal class FirAnonymousObjectExpressionImpl(
override val source: FirSourceElement?,
override var typeRef: FirTypeRef,
override var anonymousObject: FirAnonymousObject,
) : FirAnonymousObjectExpression() {
override val annotations: List<FirAnnotationCall>
get() = anonymousObject.annotations
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
typeRef.accept(visitor, data)
anonymousObject.accept(visitor, data)
}
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirAnonymousObjectExpressionImpl {
typeRef = typeRef.transform(transformer, data)
transformAnonymousObject(transformer, data)
return this
}
override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirAnonymousObjectExpressionImpl {
return this
}
override fun <D> transformAnonymousObject(transformer: FirTransformer<D>, data: D): FirAnonymousObjectExpressionImpl {
anonymousObject = anonymousObject.transform(transformer, data)
return this
}
override fun replaceTypeRef(newTypeRef: FirTypeRef) {
typeRef = newTypeRef
}
}
@@ -337,7 +337,6 @@ object BuilderConfigurator : AbstractBuilderConfigurator<FirTreeBuilder>(FirTree
val elementsWithDefaultTypeRef = listOf(
thisReceiverExpression,
callableReferenceAccess,
anonymousObject,
qualifiedAccessExpression,
functionCall,
anonymousFunction,
@@ -59,7 +59,9 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
val file = element("File", Declaration, annotatedDeclaration)
val anonymousFunction = element("AnonymousFunction", Declaration, function, expression, typeParametersOwner)
val anonymousObject = element("AnonymousObject", Declaration, klass, controlFlowGraphOwner, expression)
val anonymousObject = element("AnonymousObject", Declaration, klass, controlFlowGraphOwner)
val anonymousObjectExpression = element("AnonymousObjectExpression", Expression, expression)
val diagnosticHolder = element("DiagnosticHolder", Diagnostics)
@@ -36,6 +36,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
}
impl(anonymousObject)
noImpl(anonymousObjectExpression)
impl(typeAlias)
@@ -507,7 +508,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
"FirTypeProjectionWithVarianceImpl",
"FirCallableReferenceAccessImpl",
"FirThisReceiverExpressionImpl",
"FirAnonymousObjectImpl",
"FirQualifiedAccessExpressionImpl",
"FirFunctionCallImpl",
"FirAnonymousFunctionImpl",
@@ -269,6 +269,10 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
+symbol("FirAnonymousObjectSymbol")
}
anonymousObjectExpression.configure {
+field(anonymousObject).withTransform()
}
typeAlias.configure {
+typeParameters
parentArg(classLikeDeclaration, "F", typeAlias)