[FIR] Properly support smartcasts on stable when subjects in when conditions

^KT-49860 Fixed
This commit is contained in:
Dmitriy Novozhilov
2021-11-24 17:14:21 +03:00
committed by teamcityserver
parent 20425fb458
commit 330574cab6
41 changed files with 1225 additions and 791 deletions
@@ -234,108 +234,113 @@ digraph when_kt {
subgraph cluster_23 {
color=blue
83 [label="Enter when branch condition "];
84 [label="Type operator: ($subj$ is R|A|)"];
85 [label="Exit when branch condition"];
84 [label="Exit $subj"];
85 [label="Type operator: ($subj$ is R|A|)"];
86 [label="Exit when branch condition"];
}
subgraph cluster_24 {
color=blue
86 [label="Enter when branch condition "];
87 [label="Type operator: ($subj$ is R|B|)"];
88 [label="Exit when branch condition"];
87 [label="Enter when branch condition "];
88 [label="Exit $subj"];
89 [label="Type operator: ($subj$ is R|B|)"];
90 [label="Exit when branch condition"];
}
89 [label="Synthetic else branch"];
90 [label="Enter when branch result"];
91 [label="Synthetic else branch"];
92 [label="Enter when branch result"];
subgraph cluster_25 {
color=blue
91 [label="Enter block"];
92 [label="Access variable R|<local>/x|"];
93 [label="Function call: R|<local>/x|.R|/B.bar|()"];
94 [label="Exit block"];
93 [label="Enter block"];
94 [label="Access variable R|<local>/x|"];
95 [label="Function call: R|<local>/x|.R|/B.bar|()"];
96 [label="Exit block"];
}
95 [label="Exit when branch result"];
96 [label="Enter when branch result"];
97 [label="Exit when branch result"];
98 [label="Enter when branch result"];
subgraph cluster_26 {
color=blue
97 [label="Enter block"];
98 [label="Access variable R|<local>/x|"];
99 [label="Function call: R|<local>/x|.R|/A.foo|()"];
100 [label="Exit block"];
99 [label="Enter block"];
100 [label="Access variable R|<local>/x|"];
101 [label="Function call: R|<local>/x|.R|/A.foo|()"];
102 [label="Exit block"];
}
101 [label="Exit when branch result"];
102 [label="Exit when"];
103 [label="Exit when branch result"];
104 [label="Exit when"];
}
subgraph cluster_27 {
color=blue
103 [label="Enter when"];
104 [label="Access variable R|<local>/x|"];
105 [label="Enter when"];
106 [label="Access variable R|<local>/x|"];
subgraph cluster_28 {
color=blue
105 [label="Enter when branch condition "];
106 [label="Type operator: ($subj$ !is R|A|)"];
107 [label="Exit when branch condition"];
107 [label="Enter when branch condition "];
108 [label="Exit $subj"];
109 [label="Type operator: ($subj$ !is R|A|)"];
110 [label="Exit when branch condition"];
}
subgraph cluster_29 {
color=blue
108 [label="Enter when branch condition "];
109 [label="Type operator: ($subj$ !is R|B|)"];
110 [label="Exit when branch condition"];
111 [label="Enter when branch condition "];
112 [label="Exit $subj"];
113 [label="Type operator: ($subj$ !is R|B|)"];
114 [label="Exit when branch condition"];
}
subgraph cluster_30 {
color=blue
111 [label="Enter when branch condition "];
112 [label="Type operator: ($subj$ is R|kotlin/Int|)"];
113 [label="Exit when branch condition"];
115 [label="Enter when branch condition "];
116 [label="Exit $subj"];
117 [label="Type operator: ($subj$ is R|kotlin/Int|)"];
118 [label="Exit when branch condition"];
}
subgraph cluster_31 {
color=blue
114 [label="Enter when branch condition else"];
115 [label="Exit when branch condition"];
119 [label="Enter when branch condition else"];
120 [label="Exit when branch condition"];
}
116 [label="Enter when branch result"];
121 [label="Enter when branch result"];
subgraph cluster_32 {
color=blue
117 [label="Enter block"];
118 [label="Access variable R|<local>/x|"];
119 [label="Function call: R|<local>/x|.R|/A.foo|()"];
120 [label="Access variable R|<local>/x|"];
121 [label="Function call: R|<local>/x|.R|/B.bar|()"];
122 [label="Exit block"];
122 [label="Enter block"];
123 [label="Access variable R|<local>/x|"];
124 [label="Function call: R|<local>/x|.R|/A.foo|()"];
125 [label="Access variable R|<local>/x|"];
126 [label="Function call: R|<local>/x|.R|/B.bar|()"];
127 [label="Exit block"];
}
123 [label="Exit when branch result"];
124 [label="Enter when branch result"];
128 [label="Exit when branch result"];
129 [label="Enter when branch result"];
subgraph cluster_33 {
color=blue
125 [label="Enter block"];
126 [label="Access variable R|<local>/x|"];
127 [label="Function call: R|<local>/x|.R|/A.foo|()"];
128 [label="Access variable R|<local>/x|"];
129 [label="Function call: R|<local>/x|.R|/B.bar|()"];
130 [label="Access variable R|<local>/x|"];
131 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
132 [label="Exit block"];
130 [label="Enter block"];
131 [label="Access variable R|<local>/x|"];
132 [label="Function call: R|<local>/x|.R|/A.foo|()"];
133 [label="Access variable R|<local>/x|"];
134 [label="Function call: R|<local>/x|.R|/B.bar|()"];
135 [label="Access variable R|<local>/x|"];
136 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
137 [label="Exit block"];
}
133 [label="Exit when branch result"];
134 [label="Enter when branch result"];
138 [label="Exit when branch result"];
139 [label="Enter when branch result"];
subgraph cluster_34 {
color=blue
135 [label="Enter block"];
136 [label="Access variable R|<local>/x|"];
137 [label="Function call: R|<local>/x|.R|/A.foo|()"];
138 [label="Exit block"];
140 [label="Enter block"];
141 [label="Access variable R|<local>/x|"];
142 [label="Function call: R|<local>/x|.R|/A.foo|()"];
143 [label="Exit block"];
}
139 [label="Exit when branch result"];
140 [label="Enter when branch result"];
144 [label="Exit when branch result"];
145 [label="Enter when branch result"];
subgraph cluster_35 {
color=blue
141 [label="Enter block"];
142 [label="Exit block"];
146 [label="Enter block"];
147 [label="Exit block"];
}
143 [label="Exit when branch result"];
144 [label="Exit when"];
148 [label="Exit when branch result"];
149 [label="Exit when"];
}
145 [label="Exit block"];
150 [label="Exit block"];
}
146 [label="Exit function test_2" style="filled" fillcolor=red];
151 [label="Exit function test_2" style="filled" fillcolor=red];
}
79 -> {80};
80 -> {81};
@@ -343,19 +348,19 @@ digraph when_kt {
82 -> {83};
83 -> {84};
84 -> {85};
85 -> {96 86};
86 -> {87};
85 -> {86};
86 -> {98 87};
87 -> {88};
88 -> {90 89};
89 -> {102};
90 -> {91};
91 -> {92};
88 -> {89};
89 -> {90};
90 -> {92 91};
91 -> {104};
92 -> {93};
93 -> {94};
94 -> {95};
95 -> {102};
95 -> {96};
96 -> {97};
97 -> {98};
97 -> {104};
98 -> {99};
99 -> {100};
100 -> {101};
@@ -365,207 +370,212 @@ digraph when_kt {
104 -> {105};
105 -> {106};
106 -> {107};
107 -> {140 108};
107 -> {108};
108 -> {109};
109 -> {110};
110 -> {134 111};
110 -> {145 111};
111 -> {112};
112 -> {113};
113 -> {124 114};
114 -> {115};
113 -> {114};
114 -> {139 115};
115 -> {116};
116 -> {117};
117 -> {118};
118 -> {119};
118 -> {129 119};
119 -> {120};
120 -> {121};
121 -> {122};
122 -> {123};
123 -> {144};
123 -> {124};
124 -> {125};
125 -> {126};
126 -> {127};
127 -> {128};
128 -> {129};
128 -> {149};
129 -> {130};
130 -> {131};
131 -> {132};
132 -> {133};
133 -> {144};
133 -> {134};
134 -> {135};
135 -> {136};
136 -> {137};
137 -> {138};
138 -> {139};
139 -> {144};
138 -> {149};
139 -> {140};
140 -> {141};
141 -> {142};
142 -> {143};
143 -> {144};
144 -> {145};
144 -> {149};
145 -> {146};
subgraph cluster_36 {
color=red
147 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_37 {
color=blue
148 [label="Enter block"];
subgraph cluster_38 {
color=blue
149 [label="Enter when"];
150 [label="Access variable R|<local>/x|"];
151 [label="Variable declaration: lval y: R|kotlin/Any?|"];
subgraph cluster_39 {
color=blue
152 [label="Enter when branch condition "];
153 [label="Type operator: ($subj$ is R|A|)"];
154 [label="Exit when branch condition"];
}
subgraph cluster_40 {
color=blue
155 [label="Enter when branch condition "];
156 [label="Type operator: ($subj$ is R|B|)"];
157 [label="Exit when branch condition"];
}
158 [label="Synthetic else branch"];
159 [label="Enter when branch result"];
subgraph cluster_41 {
color=blue
160 [label="Enter block"];
161 [label="Access variable R|<local>/x|"];
162 [label="Function call: R|<local>/x|.R|/B.bar|()"];
163 [label="Access variable R|<local>/y|"];
164 [label="Function call: R|<local>/y|.R|/B.bar|()"];
165 [label="Exit block"];
}
166 [label="Exit when branch result"];
167 [label="Enter when branch result"];
subgraph cluster_42 {
color=blue
168 [label="Enter block"];
169 [label="Access variable R|<local>/x|"];
170 [label="Function call: R|<local>/x|.R|/A.foo|()"];
171 [label="Access variable R|<local>/y|"];
172 [label="Function call: R|<local>/y|.R|/A.foo|()"];
173 [label="Exit block"];
}
174 [label="Exit when branch result"];
175 [label="Exit when"];
}
subgraph cluster_43 {
color=blue
176 [label="Enter when"];
177 [label="Access variable R|<local>/x|"];
178 [label="Variable declaration: lval y: R|kotlin/Any?|"];
subgraph cluster_44 {
color=blue
179 [label="Enter when branch condition "];
180 [label="Type operator: ($subj$ !is R|A|)"];
181 [label="Exit when branch condition"];
}
subgraph cluster_45 {
color=blue
182 [label="Enter when branch condition "];
183 [label="Type operator: ($subj$ !is R|B|)"];
184 [label="Exit when branch condition"];
}
subgraph cluster_46 {
color=blue
185 [label="Enter when branch condition "];
186 [label="Type operator: ($subj$ is R|kotlin/Int|)"];
187 [label="Exit when branch condition"];
}
subgraph cluster_47 {
color=blue
188 [label="Enter when branch condition else"];
189 [label="Exit when branch condition"];
}
190 [label="Enter when branch result"];
subgraph cluster_48 {
color=blue
191 [label="Enter block"];
192 [label="Access variable R|<local>/x|"];
193 [label="Function call: R|<local>/x|.R|/A.foo|()"];
194 [label="Access variable R|<local>/x|"];
195 [label="Function call: R|<local>/x|.R|/B.bar|()"];
196 [label="Access variable R|<local>/y|"];
197 [label="Function call: R|<local>/y|.R|/A.foo|()"];
198 [label="Access variable R|<local>/y|"];
199 [label="Function call: R|<local>/y|.R|/B.bar|()"];
200 [label="Exit block"];
}
201 [label="Exit when branch result"];
202 [label="Enter when branch result"];
subgraph cluster_49 {
color=blue
203 [label="Enter block"];
204 [label="Access variable R|<local>/x|"];
205 [label="Function call: R|<local>/x|.R|/A.foo|()"];
206 [label="Access variable R|<local>/x|"];
207 [label="Function call: R|<local>/x|.R|/B.bar|()"];
208 [label="Access variable R|<local>/x|"];
209 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
210 [label="Access variable R|<local>/y|"];
211 [label="Function call: R|<local>/y|.R|/A.foo|()"];
212 [label="Access variable R|<local>/y|"];
213 [label="Function call: R|<local>/y|.R|/B.bar|()"];
214 [label="Access variable R|<local>/y|"];
215 [label="Function call: R|<local>/y|.R|kotlin/Int.inc|()"];
216 [label="Exit block"];
}
217 [label="Exit when branch result"];
218 [label="Enter when branch result"];
subgraph cluster_50 {
color=blue
219 [label="Enter block"];
220 [label="Access variable R|<local>/x|"];
221 [label="Function call: R|<local>/x|.R|/A.foo|()"];
222 [label="Access variable R|<local>/y|"];
223 [label="Function call: R|<local>/y|.R|/A.foo|()"];
224 [label="Exit block"];
}
225 [label="Exit when branch result"];
226 [label="Enter when branch result"];
subgraph cluster_51 {
color=blue
227 [label="Enter block"];
228 [label="Exit block"];
}
229 [label="Exit when branch result"];
230 [label="Exit when"];
}
231 [label="Exit block"];
}
232 [label="Exit function test_3" style="filled" fillcolor=red];
}
146 -> {147};
147 -> {148};
148 -> {149};
149 -> {150};
150 -> {151};
151 -> {152};
subgraph cluster_36 {
color=red
152 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_37 {
color=blue
153 [label="Enter block"];
subgraph cluster_38 {
color=blue
154 [label="Enter when"];
155 [label="Access variable R|<local>/x|"];
156 [label="Variable declaration: lval y: R|kotlin/Any?|"];
subgraph cluster_39 {
color=blue
157 [label="Enter when branch condition "];
158 [label="Exit $subj"];
159 [label="Type operator: ($subj$ is R|A|)"];
160 [label="Exit when branch condition"];
}
subgraph cluster_40 {
color=blue
161 [label="Enter when branch condition "];
162 [label="Exit $subj"];
163 [label="Type operator: ($subj$ is R|B|)"];
164 [label="Exit when branch condition"];
}
165 [label="Synthetic else branch"];
166 [label="Enter when branch result"];
subgraph cluster_41 {
color=blue
167 [label="Enter block"];
168 [label="Access variable R|<local>/x|"];
169 [label="Function call: R|<local>/x|.R|/B.bar|()"];
170 [label="Access variable R|<local>/y|"];
171 [label="Function call: R|<local>/y|.R|/B.bar|()"];
172 [label="Exit block"];
}
173 [label="Exit when branch result"];
174 [label="Enter when branch result"];
subgraph cluster_42 {
color=blue
175 [label="Enter block"];
176 [label="Access variable R|<local>/x|"];
177 [label="Function call: R|<local>/x|.R|/A.foo|()"];
178 [label="Access variable R|<local>/y|"];
179 [label="Function call: R|<local>/y|.R|/A.foo|()"];
180 [label="Exit block"];
}
181 [label="Exit when branch result"];
182 [label="Exit when"];
}
subgraph cluster_43 {
color=blue
183 [label="Enter when"];
184 [label="Access variable R|<local>/x|"];
185 [label="Variable declaration: lval y: R|kotlin/Any?|"];
subgraph cluster_44 {
color=blue
186 [label="Enter when branch condition "];
187 [label="Exit $subj"];
188 [label="Type operator: ($subj$ !is R|A|)"];
189 [label="Exit when branch condition"];
}
subgraph cluster_45 {
color=blue
190 [label="Enter when branch condition "];
191 [label="Exit $subj"];
192 [label="Type operator: ($subj$ !is R|B|)"];
193 [label="Exit when branch condition"];
}
subgraph cluster_46 {
color=blue
194 [label="Enter when branch condition "];
195 [label="Exit $subj"];
196 [label="Type operator: ($subj$ is R|kotlin/Int|)"];
197 [label="Exit when branch condition"];
}
subgraph cluster_47 {
color=blue
198 [label="Enter when branch condition else"];
199 [label="Exit when branch condition"];
}
200 [label="Enter when branch result"];
subgraph cluster_48 {
color=blue
201 [label="Enter block"];
202 [label="Access variable R|<local>/x|"];
203 [label="Function call: R|<local>/x|.R|/A.foo|()"];
204 [label="Access variable R|<local>/x|"];
205 [label="Function call: R|<local>/x|.R|/B.bar|()"];
206 [label="Access variable R|<local>/y|"];
207 [label="Function call: R|<local>/y|.R|/A.foo|()"];
208 [label="Access variable R|<local>/y|"];
209 [label="Function call: R|<local>/y|.R|/B.bar|()"];
210 [label="Exit block"];
}
211 [label="Exit when branch result"];
212 [label="Enter when branch result"];
subgraph cluster_49 {
color=blue
213 [label="Enter block"];
214 [label="Access variable R|<local>/x|"];
215 [label="Function call: R|<local>/x|.R|/A.foo|()"];
216 [label="Access variable R|<local>/x|"];
217 [label="Function call: R|<local>/x|.R|/B.bar|()"];
218 [label="Access variable R|<local>/x|"];
219 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
220 [label="Access variable R|<local>/y|"];
221 [label="Function call: R|<local>/y|.R|/A.foo|()"];
222 [label="Access variable R|<local>/y|"];
223 [label="Function call: R|<local>/y|.R|/B.bar|()"];
224 [label="Access variable R|<local>/y|"];
225 [label="Function call: R|<local>/y|.R|kotlin/Int.inc|()"];
226 [label="Exit block"];
}
227 [label="Exit when branch result"];
228 [label="Enter when branch result"];
subgraph cluster_50 {
color=blue
229 [label="Enter block"];
230 [label="Access variable R|<local>/x|"];
231 [label="Function call: R|<local>/x|.R|/A.foo|()"];
232 [label="Access variable R|<local>/y|"];
233 [label="Function call: R|<local>/y|.R|/A.foo|()"];
234 [label="Exit block"];
}
235 [label="Exit when branch result"];
236 [label="Enter when branch result"];
subgraph cluster_51 {
color=blue
237 [label="Enter block"];
238 [label="Exit block"];
}
239 [label="Exit when branch result"];
240 [label="Exit when"];
}
241 [label="Exit block"];
}
242 [label="Exit function test_3" style="filled" fillcolor=red];
}
152 -> {153};
153 -> {154};
154 -> {167 155};
154 -> {155};
155 -> {156};
156 -> {157};
157 -> {159 158};
158 -> {175};
157 -> {158};
158 -> {159};
159 -> {160};
160 -> {161};
160 -> {174 161};
161 -> {162};
162 -> {163};
163 -> {164};
164 -> {165};
165 -> {166};
166 -> {175};
164 -> {166 165};
165 -> {182};
166 -> {167};
167 -> {168};
168 -> {169};
169 -> {170};
170 -> {171};
171 -> {172};
172 -> {173};
173 -> {174};
173 -> {182};
174 -> {175};
175 -> {176};
176 -> {177};
@@ -573,27 +583,27 @@ digraph when_kt {
178 -> {179};
179 -> {180};
180 -> {181};
181 -> {226 182};
181 -> {182};
182 -> {183};
183 -> {184};
184 -> {218 185};
184 -> {185};
185 -> {186};
186 -> {187};
187 -> {202 188};
187 -> {188};
188 -> {189};
189 -> {190};
189 -> {236 190};
190 -> {191};
191 -> {192};
192 -> {193};
193 -> {194};
193 -> {228 194};
194 -> {195};
195 -> {196};
196 -> {197};
197 -> {198};
197 -> {212 198};
198 -> {199};
199 -> {200};
200 -> {201};
201 -> {230};
201 -> {202};
202 -> {203};
203 -> {204};
204 -> {205};
@@ -603,13 +613,13 @@ digraph when_kt {
208 -> {209};
209 -> {210};
210 -> {211};
211 -> {212};
211 -> {240};
212 -> {213};
213 -> {214};
214 -> {215};
215 -> {216};
216 -> {217};
217 -> {230};
217 -> {218};
218 -> {219};
219 -> {220};
220 -> {221};
@@ -617,60 +627,61 @@ digraph when_kt {
222 -> {223};
223 -> {224};
224 -> {225};
225 -> {230};
225 -> {226};
226 -> {227};
227 -> {228};
227 -> {240};
228 -> {229};
229 -> {230};
230 -> {231};
231 -> {232};
subgraph cluster_52 {
color=red
233 [label="Enter function test_4" style="filled" fillcolor=red];
subgraph cluster_53 {
color=blue
234 [label="Enter block"];
subgraph cluster_54 {
color=blue
235 [label="Enter when"];
236 [label="Access variable R|<local>/x|"];
237 [label="Type operator: (R|<local>/x| as R|kotlin/Int|)"];
subgraph cluster_55 {
color=blue
238 [label="Enter when branch condition "];
239 [label="Const: Int(1)"];
240 [label="Equality operator =="];
241 [label="Exit when branch condition"];
}
242 [label="Synthetic else branch"];
243 [label="Enter when branch result"];
subgraph cluster_56 {
color=blue
244 [label="Enter block"];
245 [label="Access variable R|<local>/x|"];
246 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
247 [label="Exit block"];
}
248 [label="Exit when branch result"];
249 [label="Exit when"];
}
250 [label="Access variable R|<local>/x|"];
251 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
252 [label="Exit block"];
}
253 [label="Exit function test_4" style="filled" fillcolor=red];
}
232 -> {233};
233 -> {234};
234 -> {235};
235 -> {236};
235 -> {240};
236 -> {237};
237 -> {238};
238 -> {239};
239 -> {240};
240 -> {241};
241 -> {243 242};
242 -> {249};
241 -> {242};
subgraph cluster_52 {
color=red
243 [label="Enter function test_4" style="filled" fillcolor=red];
subgraph cluster_53 {
color=blue
244 [label="Enter block"];
subgraph cluster_54 {
color=blue
245 [label="Enter when"];
246 [label="Access variable R|<local>/x|"];
247 [label="Type operator: (R|<local>/x| as R|kotlin/Int|)"];
subgraph cluster_55 {
color=blue
248 [label="Enter when branch condition "];
249 [label="Exit $subj"];
250 [label="Const: Int(1)"];
251 [label="Equality operator =="];
252 [label="Exit when branch condition"];
}
253 [label="Synthetic else branch"];
254 [label="Enter when branch result"];
subgraph cluster_56 {
color=blue
255 [label="Enter block"];
256 [label="Access variable R|<local>/x|"];
257 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
258 [label="Exit block"];
}
259 [label="Exit when branch result"];
260 [label="Exit when"];
}
261 [label="Access variable R|<local>/x|"];
262 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
263 [label="Exit block"];
}
264 [label="Exit function test_4" style="filled" fillcolor=red];
}
243 -> {244};
244 -> {245};
245 -> {246};
@@ -680,6 +691,17 @@ digraph when_kt {
249 -> {250};
250 -> {251};
251 -> {252};
252 -> {253};
252 -> {254 253};
253 -> {260};
254 -> {255};
255 -> {256};
256 -> {257};
257 -> {258};
258 -> {259};
259 -> {260};
260 -> {261};
261 -> {262};
262 -> {263};
263 -> {264};
}