[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 color=red
14 [label="Enter property" style="filled" fillcolor=red]; 14 [label="Enter property" style="filled" fillcolor=red];
15 [label="Exit anonymous object"]; 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 { subgraph cluster_6 {
color=blue color=blue
@@ -58,6 +59,7 @@ digraph innerClassInAnonymousObject_kt {
15 -> {16}; 15 -> {16};
15 -> {0 12} [color=green]; 15 -> {0 12} [color=green];
15 -> {0 12} [style=dashed]; 15 -> {0 12} [style=dashed];
16 -> {17};
12 -> {13} [color=green]; 12 -> {13} [color=green];
} }
@@ -54,20 +54,21 @@ digraph localClassesWithImplicit_kt {
} }
22 [label="Exit local class test"]; 22 [label="Exit local class test"];
23 [label="Exit anonymous object"]; 23 [label="Exit anonymous object"];
24 [label="Variable declaration: lval x: R|<anonymous>|"]; 24 [label="Exit anonymous object expression"];
25 [label="Exit block"]; 25 [label="Variable declaration: lval x: R|<anonymous>|"];
26 [label="Exit block"];
} }
subgraph cluster_7 { subgraph cluster_7 {
color=blue color=blue
29 [label="Enter class <anonymous object>" style="filled" fillcolor=red]; 30 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
30 [label="Exit class <anonymous object>" style="filled" fillcolor=red]; 31 [label="Exit class <anonymous object>" style="filled" fillcolor=red];
} }
subgraph cluster_8 { subgraph cluster_8 {
color=blue color=blue
27 [label="Enter class A" style="filled" fillcolor=red]; 28 [label="Enter class A" style="filled" fillcolor=red];
28 [label="Exit 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}; 7 -> {8};
8 -> {9}; 8 -> {9};
@@ -79,91 +80,92 @@ digraph localClassesWithImplicit_kt {
14 -> {21}; 14 -> {21};
15 -> {16}; 15 -> {16};
16 -> {17}; 16 -> {17};
17 -> {26}; 17 -> {27};
17 -> {18} [style=dotted]; 17 -> {18} [style=dotted];
18 -> {19} [style=dotted]; 18 -> {19} [style=dotted];
19 -> {20} [style=dotted]; 19 -> {20} [style=dotted];
20 -> {21} [style=dotted]; 20 -> {21} [style=dotted];
21 -> {22}; 21 -> {22};
21 -> {31 34 69 87} [color=red]; 21 -> {32 35 70 88} [color=red];
22 -> {23}; 22 -> {23};
22 -> {94 97 132 150} [color=red]; 22 -> {95 98 133 151} [color=red];
22 -> {31 34 69 87 27} [color=green]; 22 -> {32 35 70 88 28} [color=green];
22 -> {31 34 69 87 27} [style=dashed]; 22 -> {32 35 70 88 28} [style=dashed];
23 -> {24}; 23 -> {24};
23 -> {94 97 132 150 29} [color=green]; 23 -> {95 98 133 151 30} [color=green];
23 -> {94 97 132 150 29} [style=dashed]; 23 -> {95 98 133 151 30} [style=dashed];
24 -> {25}; 24 -> {25};
25 -> {26}; 25 -> {26};
27 -> {28} [color=green]; 26 -> {27};
29 -> {30} [color=green]; 28 -> {29} [color=green];
30 -> {31} [color=green];
subgraph cluster_9 { subgraph cluster_9 {
color=red color=red
31 [label="Enter function <init>" style="filled" fillcolor=red]; 32 [label="Enter function <init>" style="filled" fillcolor=red];
32 [label="Delegated constructor call: super<R|kotlin/Any|>()"]; 33 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
33 [label="Exit function <init>" style="filled" fillcolor=red]; 34 [label="Exit function <init>" style="filled" fillcolor=red];
} }
31 -> {32};
32 -> {33}; 32 -> {33};
33 -> {34};
subgraph cluster_10 { subgraph cluster_10 {
color=red color=red
34 [label="Enter function foo" style="filled" fillcolor=red]; 35 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_11 { subgraph cluster_11 {
color=blue color=blue
35 [label="Enter block"]; 36 [label="Enter block"];
36 [label="Postponed enter to lambda"]; 37 [label="Postponed enter to lambda"];
subgraph cluster_12 { subgraph cluster_12 {
color=blue color=blue
43 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; 44 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_13 { subgraph cluster_13 {
color=blue color=blue
44 [label="Enter block"]; 45 [label="Enter block"];
45 [label="Access variable R|<local>/a|"]; 46 [label="Access variable R|<local>/a|"];
46 [label="Access variable R|kotlin/String.length|"]; 47 [label="Access variable R|kotlin/String.length|"];
subgraph cluster_14 { subgraph cluster_14 {
color=blue color=blue
47 [label="Enter when"]; 48 [label="Enter when"];
subgraph cluster_15 { subgraph cluster_15 {
color=blue color=blue
48 [label="Enter when branch condition "]; 49 [label="Enter when branch condition "];
49 [label="Access variable R|<local>/b|"]; 50 [label="Access variable R|<local>/b|"];
50 [label="Type operator: (R|<local>/b| is R|kotlin/String|)"]; 51 [label="Type operator: (R|<local>/b| is R|kotlin/String|)"];
51 [label="Exit when branch condition"]; 52 [label="Exit when branch condition"];
} }
subgraph cluster_16 { subgraph cluster_16 {
color=blue color=blue
52 [label="Enter when branch condition else"]; 53 [label="Enter when branch condition else"];
53 [label="Exit when branch condition"]; 54 [label="Exit when branch condition"];
} }
54 [label="Enter when branch result"]; 55 [label="Enter when branch result"];
subgraph cluster_17 { subgraph cluster_17 {
color=blue color=blue
55 [label="Enter block"]; 56 [label="Enter block"];
56 [label="Const: Int(1)"]; 57 [label="Const: Int(1)"];
57 [label="Exit block"]; 58 [label="Exit block"];
} }
58 [label="Exit when branch result"]; 59 [label="Exit when branch result"];
59 [label="Enter when branch result"]; 60 [label="Enter when branch result"];
subgraph cluster_18 { subgraph cluster_18 {
color=blue color=blue
60 [label="Enter block"]; 61 [label="Enter block"];
61 [label="Access variable R|<local>/b|"]; 62 [label="Access variable R|<local>/b|"];
62 [label="Access variable R|kotlin/String.length|"]; 63 [label="Access variable R|kotlin/String.length|"];
63 [label="Function call: this@R|/A|.R|<local>/bar|()"]; 64 [label="Function call: this@R|/A|.R|<local>/bar|()"];
64 [label="Exit block"]; 65 [label="Exit block"];
} }
65 [label="Exit when branch result"]; 66 [label="Exit when branch result"];
66 [label="Exit when"]; 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="Postponed exit from lambda"];
38 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"]; 39 [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> { 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| R|<local>/a|.R|kotlin/String.length|
^ when () { ^ when () {
(R|<local>/b| is R|kotlin/String|) -> { (R|<local>/b| is R|kotlin/String|) -> {
@@ -177,39 +179,38 @@ digraph localClassesWithImplicit_kt {
} }
)"]; )"];
40 [label="Stub" style="filled" fillcolor=gray]; 41 [label="Stub" style="filled" fillcolor=gray];
41 [label="Exit block" 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}; 35 -> {36};
36 -> {43}; 36 -> {37};
36 -> {37} [color=red]; 37 -> {44};
36 -> {43} [style=dashed]; 37 -> {38} [color=red];
37 -> {38}; 37 -> {44} [style=dashed];
38 -> {39}; 38 -> {39};
39 -> {42}; 39 -> {40};
39 -> {40} [style=dotted]; 40 -> {43};
40 -> {41} [style=dotted]; 40 -> {41} [style=dotted];
41 -> {42} [style=dotted]; 41 -> {42} [style=dotted];
43 -> {68 44}; 42 -> {43} [style=dotted];
44 -> {45}; 44 -> {69 45};
45 -> {46}; 45 -> {46};
46 -> {47}; 46 -> {47};
47 -> {48}; 47 -> {48};
48 -> {49}; 48 -> {49};
49 -> {50}; 49 -> {50};
50 -> {51}; 50 -> {51};
51 -> {59 52}; 51 -> {52};
52 -> {53}; 52 -> {60 53};
53 -> {54}; 53 -> {54};
54 -> {55}; 54 -> {55};
55 -> {56}; 55 -> {56};
56 -> {57}; 56 -> {57};
57 -> {58}; 57 -> {58};
58 -> {66}; 58 -> {59};
59 -> {60}; 59 -> {67};
60 -> {61}; 60 -> {61};
61 -> {62}; 61 -> {62};
62 -> {63}; 62 -> {63};
@@ -218,153 +219,154 @@ digraph localClassesWithImplicit_kt {
65 -> {66}; 65 -> {66};
66 -> {67}; 66 -> {67};
67 -> {68}; 67 -> {68};
68 -> {37} [color=green]; 68 -> {69};
68 -> {43} [color=green style=dashed]; 69 -> {38} [color=green];
69 -> {44} [color=green style=dashed];
subgraph cluster_19 { subgraph cluster_19 {
color=red color=red
69 [label="Enter function bar" style="filled" fillcolor=red]; 70 [label="Enter function bar" style="filled" fillcolor=red];
subgraph cluster_20 { subgraph cluster_20 {
color=blue color=blue
70 [label="Enter block"]; 71 [label="Enter block"];
71 [label="Postponed enter to lambda"]; 72 [label="Postponed enter to lambda"];
subgraph cluster_21 { subgraph cluster_21 {
color=blue color=blue
78 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; 79 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_22 { subgraph cluster_22 {
color=blue color=blue
79 [label="Enter block"]; 80 [label="Enter block"];
80 [label="Access variable R|<local>/b|"]; 81 [label="Access variable R|<local>/b|"];
81 [label="Access variable <Unresolved name: length>#"]; 82 [label="Access variable <Unresolved name: length>#"];
82 [label="Access variable R|<local>/a|"]; 83 [label="Access variable R|<local>/a|"];
83 [label="Access variable R|kotlin/String.length|"]; 84 [label="Access variable R|kotlin/String.length|"];
84 [label="Function call: this@R|/A|.R|<local>/baz|()"]; 85 [label="Function call: this@R|/A|.R|<local>/baz|()"];
85 [label="Exit block"]; 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="Postponed exit from lambda"];
73 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"]; 74 [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> { 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>/b|.<Unresolved name: length>#
R|<local>/a|.R|kotlin/String.length| R|<local>/a|.R|kotlin/String.length|
^ this@R|/A|.R|<local>/baz|() ^ this@R|/A|.R|<local>/baz|()
} }
)"]; )"];
75 [label="Stub" style="filled" fillcolor=gray]; 76 [label="Stub" style="filled" fillcolor=gray];
76 [label="Exit block" 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}; 70 -> {71};
71 -> {78}; 71 -> {72};
71 -> {72} [color=red]; 72 -> {79};
71 -> {78} [style=dashed]; 72 -> {73} [color=red];
72 -> {73}; 72 -> {79} [style=dashed];
73 -> {74}; 73 -> {74};
74 -> {77}; 74 -> {75};
74 -> {75} [style=dotted]; 75 -> {78};
75 -> {76} [style=dotted]; 75 -> {76} [style=dotted];
76 -> {77} [style=dotted]; 76 -> {77} [style=dotted];
78 -> {86 79}; 77 -> {78} [style=dotted];
79 -> {80}; 79 -> {87 80};
80 -> {81}; 80 -> {81};
81 -> {82}; 81 -> {82};
82 -> {83}; 82 -> {83};
83 -> {84}; 83 -> {84};
84 -> {85}; 84 -> {85};
85 -> {86}; 85 -> {86};
86 -> {72} [color=green]; 86 -> {87};
86 -> {78} [color=green style=dashed]; 87 -> {73} [color=green];
87 -> {79} [color=green style=dashed];
subgraph cluster_23 { subgraph cluster_23 {
color=red color=red
87 [label="Enter function baz" style="filled" fillcolor=red]; 88 [label="Enter function baz" style="filled" fillcolor=red];
subgraph cluster_24 { subgraph cluster_24 {
color=blue color=blue
88 [label="Enter block"]; 89 [label="Enter block"];
89 [label="Const: Int(1)"]; 90 [label="Const: Int(1)"];
90 [label="Jump: ^baz Int(1)"]; 91 [label="Jump: ^baz Int(1)"];
91 [label="Stub" style="filled" fillcolor=gray]; 92 [label="Stub" style="filled" fillcolor=gray];
92 [label="Exit block" 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}; 88 -> {89};
89 -> {90}; 89 -> {90};
90 -> {93}; 90 -> {91};
90 -> {91} [style=dotted]; 91 -> {94};
91 -> {92} [style=dotted]; 91 -> {92} [style=dotted];
92 -> {93} [style=dotted]; 92 -> {93} [style=dotted];
93 -> {94} [style=dotted];
subgraph cluster_25 { subgraph cluster_25 {
color=red color=red
94 [label="Enter function <init>" style="filled" fillcolor=red]; 95 [label="Enter function <init>" style="filled" fillcolor=red];
95 [label="Delegated constructor call: super<R|kotlin/Any|>()"]; 96 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
96 [label="Exit function <init>" style="filled" fillcolor=red]; 97 [label="Exit function <init>" style="filled" fillcolor=red];
} }
94 -> {95};
95 -> {96}; 95 -> {96};
96 -> {97};
subgraph cluster_26 { subgraph cluster_26 {
color=red color=red
97 [label="Enter function foo" style="filled" fillcolor=red]; 98 [label="Enter function foo" style="filled" fillcolor=red];
subgraph cluster_27 { subgraph cluster_27 {
color=blue color=blue
98 [label="Enter block"]; 99 [label="Enter block"];
99 [label="Postponed enter to lambda"]; 100 [label="Postponed enter to lambda"];
subgraph cluster_28 { subgraph cluster_28 {
color=blue color=blue
106 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; 107 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_29 { subgraph cluster_29 {
color=blue color=blue
107 [label="Enter block"]; 108 [label="Enter block"];
108 [label="Access variable R|<local>/a|"]; 109 [label="Access variable R|<local>/a|"];
109 [label="Access variable R|kotlin/String.length|"]; 110 [label="Access variable R|kotlin/String.length|"];
subgraph cluster_30 { subgraph cluster_30 {
color=blue color=blue
110 [label="Enter when"]; 111 [label="Enter when"];
subgraph cluster_31 { subgraph cluster_31 {
color=blue color=blue
111 [label="Enter when branch condition "]; 112 [label="Enter when branch condition "];
112 [label="Access variable R|<local>/b|"]; 113 [label="Access variable R|<local>/b|"];
113 [label="Type operator: (R|<local>/b| is R|kotlin/String|)"]; 114 [label="Type operator: (R|<local>/b| is R|kotlin/String|)"];
114 [label="Exit when branch condition"]; 115 [label="Exit when branch condition"];
} }
subgraph cluster_32 { subgraph cluster_32 {
color=blue color=blue
115 [label="Enter when branch condition else"]; 116 [label="Enter when branch condition else"];
116 [label="Exit when branch condition"]; 117 [label="Exit when branch condition"];
} }
117 [label="Enter when branch result"]; 118 [label="Enter when branch result"];
subgraph cluster_33 { subgraph cluster_33 {
color=blue color=blue
118 [label="Enter block"]; 119 [label="Enter block"];
119 [label="Const: Int(1)"]; 120 [label="Const: Int(1)"];
120 [label="Exit block"]; 121 [label="Exit block"];
} }
121 [label="Exit when branch result"]; 122 [label="Exit when branch result"];
122 [label="Enter when branch result"]; 123 [label="Enter when branch result"];
subgraph cluster_34 { subgraph cluster_34 {
color=blue color=blue
123 [label="Enter block"]; 124 [label="Enter block"];
124 [label="Access variable R|<local>/b|"]; 125 [label="Access variable R|<local>/b|"];
125 [label="Access variable R|kotlin/String.length|"]; 126 [label="Access variable R|kotlin/String.length|"];
126 [label="Function call: this@R|/<anonymous>|.R|/<anonymous>.bar|()"]; 127 [label="Function call: this@R|/<anonymous>|.R|/<anonymous>.bar|()"];
127 [label="Exit block"]; 128 [label="Exit block"];
} }
128 [label="Exit when branch result"]; 129 [label="Exit when branch result"];
129 [label="Exit when"]; 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="Postponed exit from lambda"];
101 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"]; 102 [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> { 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| R|<local>/a|.R|kotlin/String.length|
^ when () { ^ when () {
(R|<local>/b| is R|kotlin/String|) -> { (R|<local>/b| is R|kotlin/String|) -> {
@@ -378,39 +380,38 @@ digraph localClassesWithImplicit_kt {
} }
)"]; )"];
103 [label="Stub" style="filled" fillcolor=gray]; 104 [label="Stub" style="filled" fillcolor=gray];
104 [label="Exit block" 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}; 98 -> {99};
99 -> {106}; 99 -> {100};
99 -> {100} [color=red]; 100 -> {107};
99 -> {106} [style=dashed]; 100 -> {101} [color=red];
100 -> {101}; 100 -> {107} [style=dashed];
101 -> {102}; 101 -> {102};
102 -> {105}; 102 -> {103};
102 -> {103} [style=dotted]; 103 -> {106};
103 -> {104} [style=dotted]; 103 -> {104} [style=dotted];
104 -> {105} [style=dotted]; 104 -> {105} [style=dotted];
106 -> {131 107}; 105 -> {106} [style=dotted];
107 -> {108}; 107 -> {132 108};
108 -> {109}; 108 -> {109};
109 -> {110}; 109 -> {110};
110 -> {111}; 110 -> {111};
111 -> {112}; 111 -> {112};
112 -> {113}; 112 -> {113};
113 -> {114}; 113 -> {114};
114 -> {122 115}; 114 -> {115};
115 -> {116}; 115 -> {123 116};
116 -> {117}; 116 -> {117};
117 -> {118}; 117 -> {118};
118 -> {119}; 118 -> {119};
119 -> {120}; 119 -> {120};
120 -> {121}; 120 -> {121};
121 -> {129}; 121 -> {122};
122 -> {123}; 122 -> {130};
123 -> {124}; 123 -> {124};
124 -> {125}; 124 -> {125};
125 -> {126}; 125 -> {126};
@@ -419,85 +420,86 @@ digraph localClassesWithImplicit_kt {
128 -> {129}; 128 -> {129};
129 -> {130}; 129 -> {130};
130 -> {131}; 130 -> {131};
131 -> {100} [color=green]; 131 -> {132};
131 -> {106} [color=green style=dashed]; 132 -> {101} [color=green];
132 -> {107} [color=green style=dashed];
subgraph cluster_35 { subgraph cluster_35 {
color=red color=red
132 [label="Enter function bar" style="filled" fillcolor=red]; 133 [label="Enter function bar" style="filled" fillcolor=red];
subgraph cluster_36 { subgraph cluster_36 {
color=blue color=blue
133 [label="Enter block"]; 134 [label="Enter block"];
134 [label="Postponed enter to lambda"]; 135 [label="Postponed enter to lambda"];
subgraph cluster_37 { subgraph cluster_37 {
color=blue color=blue
141 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; 142 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_38 { subgraph cluster_38 {
color=blue color=blue
142 [label="Enter block"]; 143 [label="Enter block"];
143 [label="Access variable R|<local>/a|"]; 144 [label="Access variable R|<local>/a|"];
144 [label="Access variable R|kotlin/String.length|"]; 145 [label="Access variable R|kotlin/String.length|"];
145 [label="Access variable R|<local>/b|"]; 146 [label="Access variable R|<local>/b|"];
146 [label="Access variable <Unresolved name: length>#"]; 147 [label="Access variable <Unresolved name: length>#"];
147 [label="Function call: this@R|/<anonymous>|.R|/<anonymous>.baz|()"]; 148 [label="Function call: this@R|/<anonymous>|.R|/<anonymous>.baz|()"];
148 [label="Exit block"]; 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="Postponed exit from lambda"];
136 [label="Function call: R|/myRun|<R|kotlin/Int|>(...)"]; 137 [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> { 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>/a|.R|kotlin/String.length|
R|<local>/b|.<Unresolved name: length># R|<local>/b|.<Unresolved name: length>#
^ this@R|/<anonymous>|.R|/<anonymous>.baz|() ^ this@R|/<anonymous>|.R|/<anonymous>.baz|()
} }
)"]; )"];
138 [label="Stub" style="filled" fillcolor=gray]; 139 [label="Stub" style="filled" fillcolor=gray];
139 [label="Exit block" 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}; 133 -> {134};
134 -> {141}; 134 -> {135};
134 -> {135} [color=red]; 135 -> {142};
134 -> {141} [style=dashed]; 135 -> {136} [color=red];
135 -> {136}; 135 -> {142} [style=dashed];
136 -> {137}; 136 -> {137};
137 -> {140}; 137 -> {138};
137 -> {138} [style=dotted]; 138 -> {141};
138 -> {139} [style=dotted]; 138 -> {139} [style=dotted];
139 -> {140} [style=dotted]; 139 -> {140} [style=dotted];
141 -> {149 142}; 140 -> {141} [style=dotted];
142 -> {143}; 142 -> {150 143};
143 -> {144}; 143 -> {144};
144 -> {145}; 144 -> {145};
145 -> {146}; 145 -> {146};
146 -> {147}; 146 -> {147};
147 -> {148}; 147 -> {148};
148 -> {149}; 148 -> {149};
149 -> {135} [color=green]; 149 -> {150};
149 -> {141} [color=green style=dashed]; 150 -> {136} [color=green];
150 -> {142} [color=green style=dashed];
subgraph cluster_39 { subgraph cluster_39 {
color=red color=red
150 [label="Enter function baz" style="filled" fillcolor=red]; 151 [label="Enter function baz" style="filled" fillcolor=red];
subgraph cluster_40 { subgraph cluster_40 {
color=blue color=blue
151 [label="Enter block"]; 152 [label="Enter block"];
152 [label="Const: Int(1)"]; 153 [label="Const: Int(1)"];
153 [label="Jump: ^baz Int(1)"]; 154 [label="Jump: ^baz Int(1)"];
154 [label="Stub" style="filled" fillcolor=gray]; 155 [label="Stub" style="filled" fillcolor=gray];
155 [label="Exit block" 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}; 151 -> {152};
152 -> {153}; 152 -> {153};
153 -> {156}; 153 -> {154};
153 -> {154} [style=dotted]; 154 -> {157};
154 -> {155} [style=dotted]; 154 -> {155} [style=dotted];
155 -> {156} [style=dotted]; 155 -> {156} [style=dotted];
156 -> {157} [style=dotted];
} }
@@ -10,92 +10,94 @@ digraph inAnonymousObject_kt {
color=blue color=blue
1 [label="Enter block"]; 1 [label="Enter block"];
2 [label="Exit anonymous object"]; 2 [label="Exit anonymous object"];
3 [label="Variable declaration: lval obj: R|<anonymous>|"]; 3 [label="Exit anonymous object expression"];
4 [label="Access variable R|<local>/obj|"]; 4 [label="Variable declaration: lval obj: R|<anonymous>|"];
5 [label="Function call: R|<local>/obj|.R|/<anonymous>.run|()"]; 5 [label="Access variable R|<local>/obj|"];
6 [label="Function call: R|<local>/d|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"]; 6 [label="Function call: R|<local>/obj|.R|/<anonymous>.run|()"];
7 [label="Exit block"]; 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 { subgraph cluster_2 {
color=blue color=blue
9 [label="Enter class <anonymous object>" style="filled" fillcolor=red]; 10 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
10 [label="Part of class initialization"];
11 [label="Part of class initialization"]; 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}; 0 -> {1};
1 -> {2}; 1 -> {2};
1 -> {13 16 19 25} [color=red]; 1 -> {14 17 20 26} [color=red];
2 -> {3}; 2 -> {3};
2 -> {13 25 9} [color=green]; 2 -> {14 26 10} [color=green];
2 -> {13 25 9} [style=dashed]; 2 -> {14 26 10} [style=dashed];
3 -> {4}; 3 -> {4};
4 -> {5}; 4 -> {5};
5 -> {6}; 5 -> {6};
6 -> {7}; 6 -> {7};
7 -> {8}; 7 -> {8};
9 -> {10} [color=green]; 8 -> {9};
10 -> {11} [style=dotted]; 10 -> {11} [color=green];
10 -> {16} [color=green];
10 -> {16} [style=dashed];
11 -> {12} [style=dotted]; 11 -> {12} [style=dotted];
11 -> {19} [color=green]; 11 -> {17} [color=green];
11 -> {19} [style=dashed]; 11 -> {17} [style=dashed];
12 -> {13} [style=dotted];
12 -> {20} [color=green];
12 -> {20} [style=dashed];
subgraph cluster_3 { subgraph cluster_3 {
color=red color=red
13 [label="Enter function <init>" style="filled" fillcolor=red]; 14 [label="Enter function <init>" style="filled" fillcolor=red];
14 [label="Delegated constructor call: super<R|kotlin/Any|>()"]; 15 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
15 [label="Exit function <init>" style="filled" fillcolor=red]; 16 [label="Exit function <init>" style="filled" fillcolor=red];
} }
13 -> {14};
14 -> {15}; 14 -> {15};
15 -> {16};
subgraph cluster_4 { subgraph cluster_4 {
color=red color=red
16 [label="Enter property" style="filled" fillcolor=red]; 17 [label="Enter property" style="filled" fillcolor=red];
17 [label="Access variable R|<local>/a|"]; 18 [label="Access variable R|<local>/a|"];
18 [label="Exit property" style="filled" fillcolor=red]; 19 [label="Exit property" style="filled" fillcolor=red];
} }
16 -> {17};
17 -> {18}; 17 -> {18};
18 -> {11} [color=green]; 18 -> {19};
19 -> {12} [color=green];
subgraph cluster_5 { subgraph cluster_5 {
color=red color=red
19 [label="Enter init block" style="filled" fillcolor=red]; 20 [label="Enter init block" style="filled" fillcolor=red];
subgraph cluster_6 { subgraph cluster_6 {
color=blue color=blue
20 [label="Enter block"]; 21 [label="Enter block"];
21 [label="Access variable R|<local>/b|"]; 22 [label="Access variable R|<local>/b|"];
22 [label="Assignment: R|/<anonymous>.leaked|"]; 23 [label="Assignment: R|/<anonymous>.leaked|"];
23 [label="Exit block"]; 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}; 20 -> {21};
21 -> {22}; 21 -> {22};
22 -> {23}; 22 -> {23};
23 -> {24}; 23 -> {24};
24 -> {12} [color=green]; 24 -> {25};
25 -> {13} [color=green];
subgraph cluster_7 { subgraph cluster_7 {
color=red color=red
25 [label="Enter function run" style="filled" fillcolor=red]; 26 [label="Enter function run" style="filled" fillcolor=red];
subgraph cluster_8 { subgraph cluster_8 {
color=blue color=blue
26 [label="Enter block"]; 27 [label="Enter block"];
27 [label="Function call: R|<local>/c|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"]; 28 [label="Function call: R|<local>/c|.R|SubstitutionOverride<kotlin/Function0.invoke: R|kotlin/Unit|>|()"];
28 [label="Exit block"]; 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}; 26 -> {27};
27 -> {28}; 27 -> {28};
28 -> {29}; 28 -> {29};
29 -> {30};
} }
@@ -80,8 +80,8 @@ digraph delegateWithAnonymousObject_kt {
} }
22 -> {23} [color=green]; 22 -> {23} [color=green];
23 -> {24} [style=dotted]; 23 -> {24} [style=dotted];
23 -> {71} [color=green]; 23 -> {72} [color=green];
23 -> {71} [style=dashed]; 23 -> {72} [style=dashed];
subgraph cluster_9 { subgraph cluster_9 {
color=red color=red
@@ -94,115 +94,115 @@ digraph delegateWithAnonymousObject_kt {
subgraph cluster_10 { subgraph cluster_10 {
color=red color=red
35 [label="Enter function <init>" style="filled" fillcolor=red]; 36 [label="Enter function <init>" style="filled" fillcolor=red];
36 [label="Delegated constructor call: super<R|kotlin/Any|>()"]; 37 [label="Delegated constructor call: super<R|kotlin/Any|>()"];
37 [label="Exit function <init>" style="filled" fillcolor=red]; 38 [label="Exit function <init>" style="filled" fillcolor=red];
} }
35 -> {36};
36 -> {37}; 36 -> {37};
37 -> {38};
subgraph cluster_11 { subgraph cluster_11 {
color=red color=red
38 [label="Enter function getValue" style="filled" fillcolor=red]; 39 [label="Enter function getValue" style="filled" fillcolor=red];
subgraph cluster_12 { subgraph cluster_12 {
color=blue color=blue
39 [label="Enter block"]; 40 [label="Enter block"];
40 [label="Function call: R|/IssueListView.IssueListView|()"]; 41 [label="Function call: R|/IssueListView.IssueListView|()"];
41 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"]; 42 [label="Jump: ^getValue R|/IssueListView.IssueListView|()"];
42 [label="Stub" style="filled" fillcolor=gray]; 43 [label="Stub" style="filled" fillcolor=gray];
43 [label="Exit block" 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}; 39 -> {40};
40 -> {41}; 40 -> {41};
41 -> {44}; 41 -> {42};
41 -> {42} [style=dotted]; 42 -> {45};
42 -> {43} [style=dotted]; 42 -> {43} [style=dotted];
43 -> {44} [style=dotted]; 43 -> {44} [style=dotted];
44 -> {45} [style=dotted];
subgraph cluster_13 { subgraph cluster_13 {
color=red color=red
45 [label="Enter function setValue" style="filled" fillcolor=red]; 46 [label="Enter function setValue" style="filled" fillcolor=red];
subgraph cluster_14 { subgraph cluster_14 {
color=blue color=blue
46 [label="Enter block"]; 47 [label="Enter block"];
47 [label="Function call: R|/IssueListView.IssueListView|()"]; 48 [label="Function call: R|/IssueListView.IssueListView|()"];
48 [label="Access variable R|<local>/value|"]; 49 [label="Access variable R|<local>/value|"];
49 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)"]; 50 [label="Function call: R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(...)"];
50 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|<local>/value|)"]; 51 [label="Jump: ^setValue R|/IssueListView.IssueListView|().R|/IssueListView.updateFrom|(R|<local>/value|)"];
51 [label="Stub" style="filled" fillcolor=gray]; 52 [label="Stub" style="filled" fillcolor=gray];
52 [label="Exit block" 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}; 46 -> {47};
47 -> {48}; 47 -> {48};
48 -> {49}; 48 -> {49};
49 -> {50}; 49 -> {50};
50 -> {53}; 50 -> {51};
50 -> {51} [style=dotted]; 51 -> {54};
51 -> {52} [style=dotted]; 51 -> {52} [style=dotted];
52 -> {53} [style=dotted]; 52 -> {53} [style=dotted];
53 -> {54} [style=dotted];
subgraph cluster_15 { subgraph cluster_15 {
color=red color=red
54 [label="Enter function getter" style="filled" fillcolor=red]; 55 [label="Enter function getter" style="filled" fillcolor=red];
subgraph cluster_16 { subgraph cluster_16 {
color=blue color=blue
55 [label="Enter block"]; 56 [label="Enter block"];
56 [label="Access variable D|/IssuesListUserProfile.issueListView|"]; 57 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
57 [label="Access variable this@R|/IssuesListUserProfile|"]; 58 [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="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="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="Stub" style="filled" fillcolor=gray];
61 [label="Exit block" 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}; 55 -> {56};
56 -> {57}; 56 -> {57};
57 -> {58}; 57 -> {58};
58 -> {59}; 58 -> {59};
59 -> {62}; 59 -> {60};
59 -> {60} [style=dotted]; 60 -> {63};
60 -> {61} [style=dotted]; 60 -> {61} [style=dotted];
61 -> {62} [style=dotted]; 61 -> {62} [style=dotted];
62 -> {63} [style=dotted];
subgraph cluster_17 { subgraph cluster_17 {
color=red color=red
63 [label="Enter function setter" style="filled" fillcolor=red]; 64 [label="Enter function setter" style="filled" fillcolor=red];
subgraph cluster_18 { subgraph cluster_18 {
color=blue color=blue
64 [label="Enter block"]; 65 [label="Enter block"];
65 [label="Access variable D|/IssuesListUserProfile.issueListView|"]; 66 [label="Access variable D|/IssuesListUserProfile.issueListView|"];
66 [label="Access variable this@R|/IssuesListUserProfile|"]; 67 [label="Access variable this@R|/IssuesListUserProfile|"];
67 [label="Access variable R|<local>/issueListView|"]; 68 [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="Function call: this@R|/IssuesListUserProfile|.D|/IssuesListUserProfile.issueListView|.R|SubstitutionOverride<kotlin/properties/ReadWriteProperty.setValue: R|kotlin/Unit|>|(...)"];
69 [label="Exit block"]; 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}; 64 -> {65};
65 -> {66}; 65 -> {66};
66 -> {67}; 66 -> {67};
67 -> {68}; 67 -> {68};
68 -> {69}; 68 -> {69};
69 -> {70}; 69 -> {70};
70 -> {71};
subgraph cluster_19 { subgraph cluster_19 {
color=red color=red
71 [label="Enter property" style="filled" fillcolor=red]; 72 [label="Enter property" style="filled" fillcolor=red];
72 [label="Postponed enter to lambda"]; 73 [label="Postponed enter to lambda"];
73 [label="Postponed exit from lambda"]; 74 [label="Postponed exit from lambda"];
74 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)"]; 75 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)"];
75 [label="Access variable this@R|/IssuesListUserProfile|"]; 76 [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="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...).<Unresolved name: provideDelegate>#(...)"];
77 [label="Postponed enter to lambda"]; 78 [label="Postponed enter to lambda"];
subgraph cluster_20 { subgraph cluster_20 {
color=blue color=blue
28 [label="Enter function anonymousFunction" style="filled" fillcolor=red]; 28 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
@@ -210,38 +210,40 @@ digraph delegateWithAnonymousObject_kt {
color=blue color=blue
29 [label="Enter block"]; 29 [label="Enter block"];
30 [label="Exit anonymous object"]; 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 { subgraph cluster_22 {
color=blue color=blue
33 [label="Enter class <anonymous object>" style="filled" fillcolor=red]; 34 [label="Enter class <anonymous object>" style="filled" fillcolor=red];
34 [label="Exit 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="Postponed exit from lambda"];
79 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)"]; 80 [label="Function call: this@R|/IssuesListUserProfile|.R|/delegate|<R|IssuesListUserProfile|, R|IssuesListUserProfile|, R|IssueListView|>(...)"];
80 [label="Exit property" style="filled" fillcolor=red]; 81 [label="Exit property" style="filled" fillcolor=red];
} }
71 -> {72};
72 -> {73}; 72 -> {73};
72 -> {} [style=dashed];
73 -> {74}; 73 -> {74};
73 -> {} [style=dashed];
74 -> {75}; 74 -> {75};
75 -> {76}; 75 -> {76};
76 -> {77}; 76 -> {77};
77 -> {78 28}; 77 -> {78};
77 -> {28} [style=dashed]; 78 -> {79 28};
78 -> {79}; 78 -> {28} [style=dashed];
79 -> {80}; 79 -> {80};
80 -> {24} [color=green]; 80 -> {81};
81 -> {24} [color=green];
28 -> {29}; 28 -> {29};
29 -> {30}; 29 -> {30};
29 -> {35 38 45} [color=red]; 29 -> {36 39 46} [color=red];
30 -> {31}; 30 -> {31};
30 -> {35 38 45 33} [color=green]; 30 -> {36 39 46 34} [color=green];
30 -> {35 38 45 33} [style=dashed]; 30 -> {36 39 46 34} [style=dashed];
31 -> {32}; 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.FirErrors
import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn import org.jetbrains.kotlin.fir.analysis.diagnostics.reportOn
import org.jetbrains.kotlin.fir.declarations.* 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.resolve.symbolProvider
import org.jetbrains.kotlin.fir.types.classId import org.jetbrains.kotlin.fir.types.classId
import org.jetbrains.kotlin.fir.types.coneType import org.jetbrains.kotlin.fir.types.coneType
@@ -26,8 +27,8 @@ object FirSealedSupertypeChecker : FirMemberDeclarationChecker() {
checkGlobalDeclaration(declaration, context, reporter) checkGlobalDeclaration(declaration, context, reporter)
} }
} else if (declaration is FirProperty) { } else if (declaration is FirProperty) {
val initializer = declaration.initializer.safeAs<FirClass<*>>() ?: return val initializer = declaration.initializer as? FirAnonymousObjectExpression ?: return
checkLocalDeclaration(initializer, context, reporter) 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?) { override fun visitAnonymousObject(anonymousObject: FirAnonymousObject, data: Nothing?) {
withSuppressedDiagnostics(anonymousObject) { withSuppressedDiagnostics(anonymousObject) {
visitClassAndChildren(anonymousObject, anonymousObject.defaultType()) visitClassAndChildren(anonymousObject, anonymousObject.defaultType())
@@ -1512,7 +1512,7 @@ class HtmlFirDump internal constructor(private var linkResolver: FirLinkResolver
is FirGetClassCall -> generate(expression) is FirGetClassCall -> generate(expression)
is FirContinueExpression -> generate(expression) is FirContinueExpression -> generate(expression)
is FirBreakExpression -> generate(expression) is FirBreakExpression -> generate(expression)
is FirAnonymousObject -> generate(expression) is FirAnonymousObjectExpression -> generate(expression.anonymousObject)
is FirUnitExpression -> generate(expression) is FirUnitExpression -> generate(expression)
is FirStringConcatenationCall -> generate(expression) is FirStringConcatenationCall -> generate(expression)
is FirAnonymousFunction -> generate(expression, isStatement = false) 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.Visibilities
import org.jetbrains.kotlin.descriptors.Visibility import org.jetbrains.kotlin.descriptors.Visibility
import org.jetbrains.kotlin.fir.declarations.* 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.lazy.Fir2IrLazyClass
import org.jetbrains.kotlin.fir.resolve.firProvider import org.jetbrains.kotlin.fir.resolve.firProvider
import org.jetbrains.kotlin.fir.resolve.symbolProvider import org.jetbrains.kotlin.fir.resolve.symbolProvider
@@ -368,7 +369,7 @@ class Fir2IrClassifierStorage(
} }
fun putEnumEntryClassInScope(enumEntry: FirEnumEntry, correspondingClass: IrClass) { 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] internal fun getCachedIrEnumEntry(enumEntry: FirEnumEntry): IrEnumEntry? = enumEntryCache[enumEntry]
@@ -396,10 +397,10 @@ class Fir2IrClassifierStorage(
this.parent = irParent this.parent = irParent
} }
val initializer = enumEntry.initializer val initializer = enumEntry.initializer
if (initializer is FirAnonymousObject) { if (initializer is FirAnonymousObjectExpression) {
// An enum entry with its own members // An enum entry with its own members
if (initializer.declarations.any { it !is FirConstructor }) { if (initializer.anonymousObject.declarations.any { it !is FirConstructor }) {
val klass = getIrAnonymousObjectForEnumEntry(initializer, enumEntry.name, irParent) val klass = getIrAnonymousObjectForEnumEntry(initializer.anonymousObject, enumEntry.name, irParent)
this.correspondingClass = klass this.correspondingClass = klass
} }
// Otherwise, this is a default-ish enum entry whose initializer would be a delegating constructor call, // 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 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 override fun visitAnonymousFunction(anonymousFunction: FirAnonymousFunction, data: IrElement): IrElement = data
@@ -106,7 +106,7 @@ class Fir2IrVisitor(
if (correspondingClass != null) { if (correspondingClass != null) {
declarationStorage.enterScope(irEnumEntry) declarationStorage.enterScope(irEnumEntry)
classifierStorage.putEnumEntryClassInScope(enumEntry, correspondingClass) classifierStorage.putEnumEntryClassInScope(enumEntry, correspondingClass)
val anonymousObject = enumEntry.initializer as FirAnonymousObject val anonymousObject = (enumEntry.initializer as FirAnonymousObjectExpression).anonymousObject
converter.processAnonymousObjectMembers(anonymousObject, correspondingClass) converter.processAnonymousObjectMembers(anonymousObject, correspondingClass)
conversionScope.withParent(correspondingClass) { conversionScope.withParent(correspondingClass) {
conversionScope.withContainingFirClass(anonymousObject) { conversionScope.withContainingFirClass(anonymousObject) {
@@ -123,10 +123,10 @@ class Fir2IrVisitor(
) )
} }
declarationStorage.leaveScope(irEnumEntry) 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. // 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. // 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) { if (delegatedConstructor != null) {
with(memberGenerator) { with(memberGenerator) {
irEnumEntry.initializerExpression = irFactory.createExpressionBody( 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 { override fun visitAnonymousObject(anonymousObject: FirAnonymousObject, data: Any?): IrElement {
val irParent = conversionScope.parentFromStack() val irParent = conversionScope.parentFromStack()
// NB: for implicit types it is possible that anonymous object is already cached // NB: for implicit types it is possible that anonymous object is already cached
@@ -546,8 +546,11 @@ class DeclarationsConverter(
*/ */
fun convertObjectLiteral(objectLiteral: LighterASTNode): FirElement { fun convertObjectLiteral(objectLiteral: LighterASTNode): FirElement {
return withChildClassName(ANONYMOUS_OBJECT_NAME) { return withChildClassName(ANONYMOUS_OBJECT_NAME) {
buildAnonymousObject { buildAnonymousObjectExpression {
val objectDeclaration = objectLiteral.getChildNodesByType(OBJECT_DECLARATION).first() val objectDeclaration = objectLiteral.getChildNodesByType(OBJECT_DECLARATION).first()
val sourceElement = objectDeclaration.toFirSourceElement()
source = sourceElement
anonymousObject = buildAnonymousObject {
source = objectDeclaration.toFirSourceElement() source = objectDeclaration.toFirSourceElement()
origin = FirDeclarationOrigin.Source origin = FirDeclarationOrigin.Source
moduleData = baseModuleData moduleData = baseModuleData
@@ -555,8 +558,7 @@ class DeclarationsConverter(
scopeProvider = baseScopeProvider scopeProvider = baseScopeProvider
symbol = FirAnonymousObjectSymbol() symbol = FirAnonymousObjectSymbol()
context.applyToActualCapturedTypeParameters(false) { context.applyToActualCapturedTypeParameters(false) {
typeParameters += buildOuterClassTypeParameterRef { this.symbol = it } typeParameters += buildOuterClassTypeParameterRef { this.symbol = it } }
}
val delegatedSelfType = objectLiteral.toDelegatedSelfType(this) val delegatedSelfType = objectLiteral.toDelegatedSelfType(this)
registerSelfType(delegatedSelfType) registerSelfType(delegatedSelfType)
@@ -592,7 +594,7 @@ class DeclarationsConverter(
annotations += modifiers.annotations annotations += modifiers.annotations
this.superTypeRefs += superTypeRefs this.superTypeRefs += superTypeRefs
typeRef = delegatedSelfType this@buildAnonymousObjectExpression.typeRef = delegatedSelfType
val classWrapper = ClassWrapper( val classWrapper = ClassWrapper(
SpecialNames.NO_NAME_PROVIDED, modifiers, ClassKind.OBJECT, this, SpecialNames.NO_NAME_PROVIDED, modifiers, ClassKind.OBJECT, this,
@@ -605,7 +607,7 @@ class DeclarationsConverter(
) )
//parse primary constructor //parse primary constructor
convertPrimaryConstructor( convertPrimaryConstructor(
primaryConstructor, typeRef.source, classWrapper, delegatedConstructorSource primaryConstructor, delegatedSelfType.source, classWrapper, delegatedConstructorSource
)?.let { this.declarations += it.firConstructor } )?.let { this.declarations += it.firConstructor }
delegateFields?.let { this.declarations += it } delegateFields?.let { this.declarations += it }
@@ -616,6 +618,7 @@ class DeclarationsConverter(
} }
} }
} }
}
/** /**
* @see org.jetbrains.kotlin.parsing.KotlinParsing.parseEnumEntry * @see org.jetbrains.kotlin.parsing.KotlinParsing.parseEnumEntry
@@ -659,8 +662,11 @@ class DeclarationsConverter(
} }
annotations += modifiers.annotations annotations += modifiers.annotations
initializer = withChildClassName(enumEntryName) { initializer = withChildClassName(enumEntryName) {
buildAnonymousObject { buildAnonymousObjectExpression {
source = enumEntry.toFirSourceElement(FirFakeSourceElementKind.EnumInitializer) val entrySource = enumEntry.toFirSourceElement(FirFakeSourceElementKind.EnumInitializer)
source = entrySource
anonymousObject = buildAnonymousObject {
source = entrySource
moduleData = baseModuleData moduleData = baseModuleData
origin = FirDeclarationOrigin.Source origin = FirDeclarationOrigin.Source
classKind = ClassKind.ENUM_ENTRY classKind = ClassKind.ENUM_ENTRY
@@ -698,6 +704,7 @@ class DeclarationsConverter(
} }
} }
} }
}
}.also { }.also {
it.containingClassAttr = currentDispatchReceiverType()!!.lookupTag it.containingClassAttr = currentDispatchReceiverType()!!.lookupTag
} }
@@ -758,8 +758,11 @@ open class RawFirBuilder(
} }
extractAnnotationsTo(this) extractAnnotationsTo(this)
initializer = withChildClassName(nameAsSafeName) { initializer = withChildClassName(nameAsSafeName) {
buildAnonymousObject { buildAnonymousObjectExpression {
source = toFirSourceElement(FirFakeSourceElementKind.EnumInitializer) val enumEntrySource = toFirSourceElement(FirFakeSourceElementKind.EnumInitializer)
source = enumEntrySource
anonymousObject = buildAnonymousObject {
source = enumEntrySource
moduleData = baseModuleData moduleData = baseModuleData
origin = FirDeclarationOrigin.Source origin = FirDeclarationOrigin.Source
classKind = ClassKind.ENUM_ENTRY classKind = ClassKind.ENUM_ENTRY
@@ -768,7 +771,8 @@ open class RawFirBuilder(
extractAnnotationsTo(this) extractAnnotationsTo(this)
val delegatedEntrySelfType = buildResolvedTypeRef { val delegatedEntrySelfType = buildResolvedTypeRef {
type = ConeClassLikeTypeImpl(this@buildAnonymousObject.symbol.toLookupTag(), emptyArray(), isNullable = false) type =
ConeClassLikeTypeImpl(this@buildAnonymousObject.symbol.toLookupTag(), emptyArray(), isNullable = false)
} }
registerSelfType(delegatedEntrySelfType) registerSelfType(delegatedEntrySelfType)
@@ -799,6 +803,7 @@ open class RawFirBuilder(
} }
} }
} }
}
}.apply { }.apply {
containingClassAttr = currentDispatchReceiverType()!!.lookupTag containingClassAttr = currentDispatchReceiverType()!!.lookupTag
} }
@@ -943,16 +948,18 @@ open class RawFirBuilder(
override fun visitObjectLiteralExpression(expression: KtObjectLiteralExpression, data: Unit): FirElement { override fun visitObjectLiteralExpression(expression: KtObjectLiteralExpression, data: Unit): FirElement {
val objectDeclaration = expression.objectDeclaration val objectDeclaration = expression.objectDeclaration
return withChildClassName(ANONYMOUS_OBJECT_NAME, forceLocalContext = true) { return withChildClassName(ANONYMOUS_OBJECT_NAME, forceLocalContext = true) {
buildAnonymousObject { buildAnonymousObjectExpression {
source = objectDeclaration.toFirSourceElement() val sourceElement = objectDeclaration.toFirSourceElement()
source = sourceElement
anonymousObject = buildAnonymousObject {
source = sourceElement
moduleData = baseModuleData moduleData = baseModuleData
origin = FirDeclarationOrigin.Source origin = FirDeclarationOrigin.Source
classKind = ClassKind.OBJECT classKind = ClassKind.OBJECT
scopeProvider = baseScopeProvider scopeProvider = baseScopeProvider
symbol = FirAnonymousObjectSymbol() symbol = FirAnonymousObjectSymbol()
context.applyToActualCapturedTypeParameters(false) { context.applyToActualCapturedTypeParameters(false) {
typeParameters += buildOuterClassTypeParameterRef { symbol = it } typeParameters += buildOuterClassTypeParameterRef { symbol = it } }
}
val delegatedSelfType = objectDeclaration.toDelegatedSelfType(this) val delegatedSelfType = objectDeclaration.toDelegatedSelfType(this)
registerSelfType(delegatedSelfType) registerSelfType(delegatedSelfType)
objectDeclaration.extractAnnotationsTo(this) objectDeclaration.extractAnnotationsTo(this)
@@ -963,8 +970,7 @@ open class RawFirBuilder(
ClassKind.CLASS, ClassKind.CLASS,
containerTypeParameters = emptyList() containerTypeParameters = emptyList()
) )
typeRef = delegatedSelfType this@buildAnonymousObjectExpression.typeRef = delegatedSelfType
for (declaration in objectDeclaration.declarations) { for (declaration in objectDeclaration.declarations) {
declarations += declaration.toFirDeclaration( declarations += declaration.toFirDeclaration(
@@ -978,6 +984,7 @@ open class RawFirBuilder(
} }
} }
} }
}
override fun visitTypeAlias(typeAlias: KtTypeAlias, data: Unit): FirElement { override fun visitTypeAlias(typeAlias: KtTypeAlias, data: Unit): FirElement {
return withChildClassName(typeAlias.nameAsSafeName) { return withChildClassName(typeAlias.nameAsSafeName) {
@@ -118,9 +118,14 @@ fun FirRegularClass.defaultType(): ConeClassLikeTypeImpl {
} }
fun FirAnonymousObject.defaultType(): ConeClassLikeType { fun FirAnonymousObject.defaultType(): ConeClassLikeType {
return this.typeRef.coneTypeSafe() ?: ConeClassLikeTypeImpl( return ConeClassLikeTypeImpl(
symbol.toLookupTag(), symbol.toLookupTag(),
emptyArray(), typeParameters.map {
ConeTypeParameterTypeImpl(
it.symbol.toLookupTag(),
isNullable = false
)
}.toTypedArray(),
isNullable = false isNullable = false
) )
} }
@@ -309,6 +309,10 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
return controlFlowGraph return controlFlowGraph
} }
fun exitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression) {
graphBuilder.exitAnonymousObjectExpression(anonymousObjectExpression).mergeIncomingFlow()
}
// ----------------------------------- Value parameters (and it's defaults) ----------------------------------- // ----------------------------------- Value parameters (and it's defaults) -----------------------------------
fun enterValueParameter(valueParameter: FirValueParameter) { 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 ----------------------------------- // ----------------------------------- Initialization -----------------------------------
class PartOfClassInitializationNode(owner: ControlFlowGraph, override val fir: FirControlFlowGraphOwner, level: Int, id: Int) : CFGNodeWithCfgOwner<FirControlFlowGraphOwner>(owner, level, id) { 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 ClassExitNode -> "Exit class ${owner.name}"
is LocalClassExitNode -> "Exit local class ${owner.name}" is LocalClassExitNode -> "Exit local class ${owner.name}"
is AnonymousObjectExitNode -> "Exit anonymous object" is AnonymousObjectExitNode -> "Exit anonymous object"
is AnonymousObjectExpressionExitNode -> "Exit anonymous object expression"
is ContractDescriptionEnterNode -> "Enter contract description" is ContractDescriptionEnterNode -> "Enter contract description"
@@ -440,6 +440,12 @@ class ControlFlowGraphBuilder {
return node to graph return node to graph
} }
fun exitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression): AnonymousObjectExpressionExitNode {
return createAnonymousObjectExpressionExitNode(anonymousObjectExpression).also {
addNewSimpleNodeIfPossible(it)
}
}
fun visitLocalClassFunctions(klass: FirClass<*>, node: CFGNodeWithCfgOwner<*>) { fun visitLocalClassFunctions(klass: FirClass<*>, node: CFGNodeWithCfgOwner<*>) {
klass.declarations.filterIsInstance<FirFunction<*>>().forEach { function -> klass.declarations.filterIsInstance<FirFunction<*>>().forEach { function ->
val functionGraph = function.controlFlowGraphReference?.controlFlowGraph val functionGraph = function.controlFlowGraphReference?.controlFlowGraph
@@ -224,6 +224,9 @@ fun ControlFlowGraphBuilder.createPostponedLambdaEnterNode(fir: FirAnonymousFunc
fun ControlFlowGraphBuilder.createAnonymousObjectExitNode(fir: FirAnonymousObject): AnonymousObjectExitNode = fun ControlFlowGraphBuilder.createAnonymousObjectExitNode(fir: FirAnonymousObject): AnonymousObjectExitNode =
AnonymousObjectExitNode(currentGraph, fir, levelCounter, createId()) AnonymousObjectExitNode(currentGraph, fir, levelCounter, createId())
fun ControlFlowGraphBuilder.createAnonymousObjectExpressionExitNode(fir: FirAnonymousObjectExpression): AnonymousObjectExpressionExitNode =
AnonymousObjectExpressionExitNode(currentGraph, fir, levelCounter, createId())
fun ControlFlowGraphBuilder.createUnionFunctionCallArgumentsNode(fir: FirElement): UnionFunctionCallArgumentsNode = fun ControlFlowGraphBuilder.createUnionFunctionCallArgumentsNode(fir: FirElement): UnionFunctionCallArgumentsNode =
UnionFunctionCallArgumentsNode(currentGraph, fir, levelCounter, createId()) UnionFunctionCallArgumentsNode(currentGraph, fir, levelCounter, createId())
@@ -52,6 +52,10 @@ abstract class ControlFlowGraphVisitor<out R, in D> {
return visitNode(node, data) return visitNode(node, data)
} }
open fun visitAnonymousObjectExpressionExitNode(node: AnonymousObjectExpressionExitNode, data: D): R {
return visitNode(node, data)
}
open fun visitClassEnterNode(node: ClassEnterNode, data: D): R { open fun visitClassEnterNode(node: ClassEnterNode, data: D): R {
return visitNode(node, data) return visitNode(node, data)
} }
@@ -137,7 +137,7 @@ open class FirApplySupertypesTransformer(
override fun transformAnonymousObject(anonymousObject: FirAnonymousObject, data: Any?): FirStatement { override fun transformAnonymousObject(anonymousObject: FirAnonymousObject, data: Any?): FirStatement {
applyResolvedSupertypesToClass(anonymousObject) applyResolvedSupertypesToClass(anonymousObject)
return super.transformAnonymousObject(anonymousObject, data) return anonymousObject.transformChildren(this, data) as FirAnonymousObject
} }
private fun getResolvedSupertypeRefs(classLikeDeclaration: FirClassLikeDeclaration<*>): List<FirResolvedTypeRef> { private fun getResolvedSupertypeRefs(classLikeDeclaration: FirClassLikeDeclaration<*>): List<FirResolvedTypeRef> {
@@ -271,6 +271,13 @@ open class FirBodyResolveTransformer(
return declarationsTransformer.transformAnonymousObject(anonymousObject, data) return declarationsTransformer.transformAnonymousObject(anonymousObject, data)
} }
override fun transformAnonymousObjectExpression(
anonymousObjectExpression: FirAnonymousObjectExpression,
data: ResolutionMode
): FirStatement {
return expressionsTransformer.transformAnonymousObjectExpression(anonymousObjectExpression, data)
}
override fun transformSimpleFunction( override fun transformSimpleFunction(
simpleFunction: FirSimpleFunction, simpleFunction: FirSimpleFunction,
data: ResolutionMode data: ResolutionMode
@@ -422,12 +422,6 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
) )
} }
dataFlowAnalyzer.enterClass() dataFlowAnalyzer.enterClass()
if (anonymousObject.typeRef !is FirResolvedTypeRef) {
anonymousObject.resultType = buildResolvedTypeRef {
source = anonymousObject.source
this.type = anonymousObject.defaultType()
}
}
val result = context.withAnonymousObject(anonymousObject, components) { val result = context.withAnonymousObject(anonymousObject, components) {
transformDeclarationContent(anonymousObject, data) as FirAnonymousObject transformDeclarationContent(anonymousObject, data) as FirAnonymousObject
} }
@@ -1063,6 +1063,21 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
return stringConcatenationCall 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 { 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.FirModuleData
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall 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.references.FirControlFlowGraphReference
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol
@@ -22,7 +21,7 @@ import org.jetbrains.kotlin.fir.visitors.*
* DO NOT MODIFY IT MANUALLY * 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 source: FirSourceElement?
abstract override val moduleData: FirModuleData abstract override val moduleData: FirModuleData
abstract override val resolvePhase: FirResolvePhase abstract override val resolvePhase: FirResolvePhase
@@ -35,7 +34,6 @@ abstract class FirAnonymousObject : FirClass<FirAnonymousObject>, FirControlFlow
abstract override val annotations: List<FirAnnotationCall> abstract override val annotations: List<FirAnnotationCall>
abstract override val scopeProvider: FirScopeProvider abstract override val scopeProvider: FirScopeProvider
abstract override val controlFlowGraphReference: FirControlFlowGraphReference? abstract override val controlFlowGraphReference: FirControlFlowGraphReference?
abstract override val typeRef: FirTypeRef
abstract override val symbol: FirAnonymousObjectSymbol abstract override val symbol: FirAnonymousObjectSymbol
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitAnonymousObject(this, data) 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 replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?)
abstract override fun replaceTypeRef(newTypeRef: FirTypeRef)
abstract override fun <D> transformTypeParameters(transformer: FirTransformer<D>, data: D): FirAnonymousObject abstract override fun <D> transformTypeParameters(transformer: FirTransformer<D>, data: D): FirAnonymousObject
abstract override fun <D> transformSuperTypeRefs(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 * DO NOT MODIFY IT MANUALLY
*/ */
sealed interface FirClass<F : FirClass<F>> : FirClassLikeDeclaration<F>, FirStatement, FirTypeParameterRefsOwner { sealed class FirClass<F : FirClass<F>> : FirClassLikeDeclaration<F>(), FirStatement, FirTypeParameterRefsOwner {
override val source: FirSourceElement? abstract override val source: FirSourceElement?
override val moduleData: FirModuleData abstract override val moduleData: FirModuleData
override val resolvePhase: FirResolvePhase abstract override val resolvePhase: FirResolvePhase
override val origin: FirDeclarationOrigin abstract override val origin: FirDeclarationOrigin
override val attributes: FirDeclarationAttributes abstract override val attributes: FirDeclarationAttributes
override val typeParameters: List<FirTypeParameterRef> abstract override val typeParameters: List<FirTypeParameterRef>
override val symbol: FirClassSymbol<F> abstract override val symbol: FirClassSymbol<F>
val classKind: ClassKind abstract val classKind: ClassKind
val superTypeRefs: List<FirTypeRef> abstract val superTypeRefs: List<FirTypeRef>
val declarations: List<FirDeclaration> abstract val declarations: List<FirDeclaration>
override val annotations: List<FirAnnotationCall> abstract override val annotations: List<FirAnnotationCall>
val scopeProvider: FirScopeProvider abstract val scopeProvider: FirScopeProvider
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitClass(this, data) 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 = override fun <E: FirElement, D> transform(transformer: FirTransformer<D>, data: D): E =
transformer.transformClass(this, data) as 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.FirElement
import org.jetbrains.kotlin.fir.FirModuleData import org.jetbrains.kotlin.fir.FirModuleData
import org.jetbrains.kotlin.fir.FirPureAbstractElement
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.FirSymbolOwner import org.jetbrains.kotlin.fir.FirSymbolOwner
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
@@ -19,14 +20,14 @@ import org.jetbrains.kotlin.fir.visitors.*
* DO NOT MODIFY IT MANUALLY * DO NOT MODIFY IT MANUALLY
*/ */
sealed interface FirClassLikeDeclaration<F : FirClassLikeDeclaration<F>> : FirAnnotatedDeclaration, FirStatement, FirSymbolOwner<F> { sealed class FirClassLikeDeclaration<F : FirClassLikeDeclaration<F>> : FirPureAbstractElement(), FirAnnotatedDeclaration, FirStatement, FirSymbolOwner<F> {
override val source: FirSourceElement? abstract override val source: FirSourceElement?
override val moduleData: FirModuleData abstract override val moduleData: FirModuleData
override val resolvePhase: FirResolvePhase abstract override val resolvePhase: FirResolvePhase
override val origin: FirDeclarationOrigin abstract override val origin: FirDeclarationOrigin
override val attributes: FirDeclarationAttributes abstract override val attributes: FirDeclarationAttributes
override val annotations: List<FirAnnotationCall> abstract override val annotations: List<FirAnnotationCall>
override val symbol: FirClassLikeSymbol<F> abstract override val symbol: FirClassLikeSymbol<F>
override fun <R, D> accept(visitor: FirVisitor<R, D>, data: D): R = visitor.visitClassLikeDeclaration(this, data) 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 = override fun <E: FirElement, D> transform(transformer: FirTransformer<D>, data: D): E =
transformer.transformClassLikeDeclaration(this, data) as 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.descriptors.ClassKind
import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.FirElement
import org.jetbrains.kotlin.fir.FirModuleData import org.jetbrains.kotlin.fir.FirModuleData
import org.jetbrains.kotlin.fir.FirPureAbstractElement
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference import org.jetbrains.kotlin.fir.references.FirControlFlowGraphReference
@@ -23,7 +22,7 @@ import org.jetbrains.kotlin.fir.visitors.*
* DO NOT MODIFY IT MANUALLY * 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 source: FirSourceElement?
abstract override val moduleData: FirModuleData abstract override val moduleData: FirModuleData
abstract override val resolvePhase: FirResolvePhase 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.FirElement
import org.jetbrains.kotlin.fir.FirModuleData import org.jetbrains.kotlin.fir.FirModuleData
import org.jetbrains.kotlin.fir.FirPureAbstractElement
import org.jetbrains.kotlin.fir.FirSourceElement import org.jetbrains.kotlin.fir.FirSourceElement
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirTypeAliasSymbol
@@ -20,7 +19,7 @@ import org.jetbrains.kotlin.fir.visitors.*
* DO NOT MODIFY IT MANUALLY * 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 source: FirSourceElement?
abstract override val moduleData: FirModuleData abstract override val moduleData: FirModuleData
abstract override val resolvePhase: FirResolvePhase 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.builder.FirDeclarationBuilder
import org.jetbrains.kotlin.fir.declarations.impl.FirAnonymousObjectImpl import org.jetbrains.kotlin.fir.declarations.impl.FirAnonymousObjectImpl
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall 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.references.FirControlFlowGraphReference
import org.jetbrains.kotlin.fir.scopes.FirScopeProvider import org.jetbrains.kotlin.fir.scopes.FirScopeProvider
import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousObjectSymbol
import org.jetbrains.kotlin.fir.types.FirTypeRef import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.impl.FirImplicitTypeRefImpl
import org.jetbrains.kotlin.fir.visitors.* import org.jetbrains.kotlin.fir.visitors.*
/* /*
@@ -35,7 +33,7 @@ import org.jetbrains.kotlin.fir.visitors.*
*/ */
@FirBuilderDsl @FirBuilderDsl
class FirAnonymousObjectBuilder : FirDeclarationBuilder, FirClassBuilder, FirAnnotationContainerBuilder, FirExpressionBuilder { class FirAnonymousObjectBuilder : FirDeclarationBuilder, FirClassBuilder, FirAnnotationContainerBuilder {
override var source: FirSourceElement? = null override var source: FirSourceElement? = null
override lateinit var moduleData: FirModuleData override lateinit var moduleData: FirModuleData
override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR
@@ -47,7 +45,6 @@ class FirAnonymousObjectBuilder : FirDeclarationBuilder, FirClassBuilder, FirAnn
override val declarations: MutableList<FirDeclaration> = mutableListOf() override val declarations: MutableList<FirDeclaration> = mutableListOf()
override val annotations: MutableList<FirAnnotationCall> = mutableListOf() override val annotations: MutableList<FirAnnotationCall> = mutableListOf()
override lateinit var scopeProvider: FirScopeProvider override lateinit var scopeProvider: FirScopeProvider
override var typeRef: FirTypeRef = FirImplicitTypeRefImpl(null)
lateinit var symbol: FirAnonymousObjectSymbol lateinit var symbol: FirAnonymousObjectSymbol
override fun build(): FirAnonymousObject { override fun build(): FirAnonymousObject {
@@ -63,7 +60,6 @@ class FirAnonymousObjectBuilder : FirDeclarationBuilder, FirClassBuilder, FirAnn
declarations, declarations,
annotations, annotations,
scopeProvider, scopeProvider,
typeRef,
symbol, symbol,
) )
} }
@@ -38,7 +38,6 @@ internal class FirAnonymousObjectImpl(
override val declarations: MutableList<FirDeclaration>, override val declarations: MutableList<FirDeclaration>,
override val annotations: MutableList<FirAnnotationCall>, override val annotations: MutableList<FirAnnotationCall>,
override val scopeProvider: FirScopeProvider, override val scopeProvider: FirScopeProvider,
override var typeRef: FirTypeRef,
override val symbol: FirAnonymousObjectSymbol, override val symbol: FirAnonymousObjectSymbol,
) : FirAnonymousObject() { ) : FirAnonymousObject() {
override var controlFlowGraphReference: FirControlFlowGraphReference? = null override var controlFlowGraphReference: FirControlFlowGraphReference? = null
@@ -53,7 +52,6 @@ internal class FirAnonymousObjectImpl(
declarations.forEach { it.accept(visitor, data) } declarations.forEach { it.accept(visitor, data) }
annotations.forEach { it.accept(visitor, data) } annotations.forEach { it.accept(visitor, data) }
controlFlowGraphReference?.accept(visitor, data) controlFlowGraphReference?.accept(visitor, data)
typeRef.accept(visitor, data)
} }
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirAnonymousObjectImpl { override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirAnonymousObjectImpl {
@@ -62,7 +60,6 @@ internal class FirAnonymousObjectImpl(
transformDeclarations(transformer, data) transformDeclarations(transformer, data)
transformAnnotations(transformer, data) transformAnnotations(transformer, data)
controlFlowGraphReference = controlFlowGraphReference?.transform(transformer, data) controlFlowGraphReference = controlFlowGraphReference?.transform(transformer, data)
typeRef = typeRef.transform(transformer, data)
return this return this
} }
@@ -98,8 +95,4 @@ internal class FirAnonymousObjectImpl(
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) { override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {
controlFlowGraphReference = newControlFlowGraphReference 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.FirFile
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject 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.diagnostics.FirDiagnosticHolder
import org.jetbrains.kotlin.fir.declarations.FirImport import org.jetbrains.kotlin.fir.declarations.FirImport
import org.jetbrains.kotlin.fir.declarations.FirResolvedImport import org.jetbrains.kotlin.fir.declarations.FirResolvedImport
@@ -302,6 +303,10 @@ abstract class FirTransformer<in D> : FirVisitor<FirElement, D>() {
return transformElement(anonymousObject, data) return transformElement(anonymousObject, data)
} }
open fun transformAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression, data: D): FirStatement {
return transformElement(anonymousObjectExpression, data)
}
open fun transformDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: D): FirDiagnosticHolder { open fun transformDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: D): FirDiagnosticHolder {
return transformElement(diagnosticHolder, data) return transformElement(diagnosticHolder, data)
} }
@@ -810,6 +815,10 @@ abstract class FirTransformer<in D> : FirVisitor<FirElement, D>() {
return transformAnonymousObject(anonymousObject, data) 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 { final override fun visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: D): FirDiagnosticHolder {
return transformDiagnosticHolder(diagnosticHolder, data) 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.FirFile
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject 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.diagnostics.FirDiagnosticHolder
import org.jetbrains.kotlin.fir.declarations.FirImport import org.jetbrains.kotlin.fir.declarations.FirImport
import org.jetbrains.kotlin.fir.declarations.FirResolvedImport 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 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 visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: D): R = visitElement(diagnosticHolder, data)
open fun visitImport(import: FirImport, data: D): R = visitElement(import, 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.FirFile
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
import org.jetbrains.kotlin.fir.declarations.FirAnonymousObject 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.diagnostics.FirDiagnosticHolder
import org.jetbrains.kotlin.fir.declarations.FirImport import org.jetbrains.kotlin.fir.declarations.FirImport
import org.jetbrains.kotlin.fir.declarations.FirResolvedImport import org.jetbrains.kotlin.fir.declarations.FirResolvedImport
@@ -301,6 +302,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
visitElement(anonymousObject) visitElement(anonymousObject)
} }
open fun visitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression) {
visitElement(anonymousObjectExpression)
}
open fun visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder) { open fun visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder) {
visitElement(diagnosticHolder) visitElement(diagnosticHolder)
} }
@@ -809,6 +814,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
visitAnonymousObject(anonymousObject) visitAnonymousObject(anonymousObject)
} }
final override fun visitAnonymousObjectExpression(anonymousObjectExpression: FirAnonymousObjectExpression, data: Nothing?) {
visitAnonymousObjectExpression(anonymousObjectExpression)
}
final override fun visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: Nothing?) { final override fun visitDiagnosticHolder(diagnosticHolder: FirDiagnosticHolder, data: Nothing?) {
visitDiagnosticHolder(diagnosticHolder) 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) { override fun visitAnonymousObject(anonymousObject: FirAnonymousObject) {
anonymousObject.annotations.renderAnnotations() anonymousObject.annotations.renderAnnotations()
print("object : ") 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( val elementsWithDefaultTypeRef = listOf(
thisReceiverExpression, thisReceiverExpression,
callableReferenceAccess, callableReferenceAccess,
anonymousObject,
qualifiedAccessExpression, qualifiedAccessExpression,
functionCall, functionCall,
anonymousFunction, anonymousFunction,
@@ -59,7 +59,9 @@ object FirTreeBuilder : AbstractFirTreeBuilder() {
val file = element("File", Declaration, annotatedDeclaration) val file = element("File", Declaration, annotatedDeclaration)
val anonymousFunction = element("AnonymousFunction", Declaration, function, expression, typeParametersOwner) 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) val diagnosticHolder = element("DiagnosticHolder", Diagnostics)
@@ -36,6 +36,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
} }
impl(anonymousObject) impl(anonymousObject)
noImpl(anonymousObjectExpression)
impl(typeAlias) impl(typeAlias)
@@ -507,7 +508,6 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
"FirTypeProjectionWithVarianceImpl", "FirTypeProjectionWithVarianceImpl",
"FirCallableReferenceAccessImpl", "FirCallableReferenceAccessImpl",
"FirThisReceiverExpressionImpl", "FirThisReceiverExpressionImpl",
"FirAnonymousObjectImpl",
"FirQualifiedAccessExpressionImpl", "FirQualifiedAccessExpressionImpl",
"FirFunctionCallImpl", "FirFunctionCallImpl",
"FirAnonymousFunctionImpl", "FirAnonymousFunctionImpl",
@@ -269,6 +269,10 @@ object NodeConfigurator : AbstractFieldConfigurator<FirTreeBuilder>(FirTreeBuild
+symbol("FirAnonymousObjectSymbol") +symbol("FirAnonymousObjectSymbol")
} }
anonymousObjectExpression.configure {
+field(anonymousObject).withTransform()
}
typeAlias.configure { typeAlias.configure {
+typeParameters +typeParameters
parentArg(classLikeDeclaration, "F", typeAlias) parentArg(classLikeDeclaration, "F", typeAlias)