FIR: Do not add alias for variables with explicit type
This commit is contained in:
committed by
TeamCityServer
parent
5317cf3af1
commit
a0a57581ec
+311
-8
@@ -592,9 +592,9 @@ digraph boundSmartcastsInBranches_kt {
|
||||
219 [label="Access variable R|<local>/x|"];
|
||||
220 [label="Access variable R|kotlin/String.length|"];
|
||||
221 [label="Access variable R|<local>/y|"];
|
||||
222 [label="Access variable R|kotlin/String.length|"];
|
||||
222 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
|
||||
223 [label="Access variable R|<local>/z|"];
|
||||
224 [label="Access variable R|kotlin/String.length|"];
|
||||
224 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
|
||||
225 [label="Exit block"];
|
||||
}
|
||||
226 [label="Exit when branch result"];
|
||||
@@ -617,11 +617,11 @@ digraph boundSmartcastsInBranches_kt {
|
||||
color=blue
|
||||
236 [label="Enter block"];
|
||||
237 [label="Access variable R|<local>/x|"];
|
||||
238 [label="Access variable R|kotlin/String.length|"];
|
||||
238 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
|
||||
239 [label="Access variable R|<local>/y|"];
|
||||
240 [label="Access variable R|kotlin/String.length|"];
|
||||
241 [label="Access variable R|<local>/z|"];
|
||||
242 [label="Access variable R|kotlin/String.length|"];
|
||||
242 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
|
||||
243 [label="Exit block"];
|
||||
}
|
||||
244 [label="Exit when branch result"];
|
||||
@@ -644,9 +644,9 @@ digraph boundSmartcastsInBranches_kt {
|
||||
color=blue
|
||||
254 [label="Enter block"];
|
||||
255 [label="Access variable R|<local>/x|"];
|
||||
256 [label="Access variable R|kotlin/String.length|"];
|
||||
256 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
|
||||
257 [label="Access variable R|<local>/y|"];
|
||||
258 [label="Access variable R|kotlin/String.length|"];
|
||||
258 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
|
||||
259 [label="Access variable R|<local>/z|"];
|
||||
260 [label="Access variable R|kotlin/String.length|"];
|
||||
261 [label="Exit block"];
|
||||
@@ -677,7 +677,7 @@ digraph boundSmartcastsInBranches_kt {
|
||||
277 [label="Access variable R|<local>/y|"];
|
||||
278 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
|
||||
279 [label="Access variable R|<local>/z|"];
|
||||
280 [label="Access variable R|kotlin/String.length|"];
|
||||
280 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
|
||||
281 [label="Exit block"];
|
||||
}
|
||||
282 [label="Exit when branch result"];
|
||||
@@ -728,7 +728,7 @@ digraph boundSmartcastsInBranches_kt {
|
||||
color=blue
|
||||
311 [label="Enter block"];
|
||||
312 [label="Access variable R|<local>/x|"];
|
||||
313 [label="Access variable R|kotlin/String.length|"];
|
||||
313 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
|
||||
314 [label="Access variable R|<local>/y|"];
|
||||
315 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
|
||||
316 [label="Access variable R|<local>/z|"];
|
||||
@@ -864,4 +864,307 @@ digraph boundSmartcastsInBranches_kt {
|
||||
320 -> {321};
|
||||
321 -> {322};
|
||||
|
||||
subgraph cluster_70 {
|
||||
color=red
|
||||
323 [label="Enter function test_8" style="filled" fillcolor=red];
|
||||
subgraph cluster_71 {
|
||||
color=blue
|
||||
324 [label="Enter block"];
|
||||
325 [label="Const: Null(null)"];
|
||||
326 [label="Variable declaration: lval z: R|kotlin/String?|"];
|
||||
327 [label="Access variable R|<local>/z|"];
|
||||
328 [label="Variable declaration: lvar y: R|kotlin/String?|"];
|
||||
329 [label="Access variable R|<local>/y|"];
|
||||
330 [label="Variable declaration: lval x: R|kotlin/String?|"];
|
||||
subgraph cluster_72 {
|
||||
color=blue
|
||||
331 [label="Enter when"];
|
||||
subgraph cluster_73 {
|
||||
color=blue
|
||||
332 [label="Enter when branch condition "];
|
||||
333 [label="Access variable R|<local>/x|"];
|
||||
334 [label="Const: Null(null)"];
|
||||
335 [label="Equality operator !="];
|
||||
336 [label="Exit when branch condition"];
|
||||
}
|
||||
337 [label="Synthetic else branch"];
|
||||
338 [label="Enter when branch result"];
|
||||
subgraph cluster_74 {
|
||||
color=blue
|
||||
339 [label="Enter block"];
|
||||
340 [label="Access variable R|<local>/x|"];
|
||||
341 [label="Access variable R|kotlin/String.length|"];
|
||||
342 [label="Access variable R|<local>/y|"];
|
||||
343 [label="Access variable R|kotlin/String.length|"];
|
||||
344 [label="Access variable R|<local>/z|"];
|
||||
345 [label="Access variable R|kotlin/String.length|"];
|
||||
346 [label="Exit block"];
|
||||
}
|
||||
347 [label="Exit when branch result"];
|
||||
348 [label="Exit when"];
|
||||
}
|
||||
subgraph cluster_75 {
|
||||
color=blue
|
||||
349 [label="Enter when"];
|
||||
subgraph cluster_76 {
|
||||
color=blue
|
||||
350 [label="Enter when branch condition "];
|
||||
351 [label="Access variable R|<local>/y|"];
|
||||
352 [label="Const: Null(null)"];
|
||||
353 [label="Equality operator !="];
|
||||
354 [label="Exit when branch condition"];
|
||||
}
|
||||
355 [label="Synthetic else branch"];
|
||||
356 [label="Enter when branch result"];
|
||||
subgraph cluster_77 {
|
||||
color=blue
|
||||
357 [label="Enter block"];
|
||||
358 [label="Access variable R|<local>/x|"];
|
||||
359 [label="Access variable R|kotlin/String.length|"];
|
||||
360 [label="Access variable R|<local>/y|"];
|
||||
361 [label="Access variable R|kotlin/String.length|"];
|
||||
362 [label="Access variable R|<local>/z|"];
|
||||
363 [label="Access variable R|kotlin/String.length|"];
|
||||
364 [label="Exit block"];
|
||||
}
|
||||
365 [label="Exit when branch result"];
|
||||
366 [label="Exit when"];
|
||||
}
|
||||
subgraph cluster_78 {
|
||||
color=blue
|
||||
367 [label="Enter when"];
|
||||
subgraph cluster_79 {
|
||||
color=blue
|
||||
368 [label="Enter when branch condition "];
|
||||
369 [label="Access variable R|<local>/z|"];
|
||||
370 [label="Const: Null(null)"];
|
||||
371 [label="Equality operator !="];
|
||||
372 [label="Exit when branch condition"];
|
||||
}
|
||||
373 [label="Synthetic else branch"];
|
||||
374 [label="Enter when branch result"];
|
||||
subgraph cluster_80 {
|
||||
color=blue
|
||||
375 [label="Enter block"];
|
||||
376 [label="Access variable R|<local>/x|"];
|
||||
377 [label="Access variable R|kotlin/String.length|"];
|
||||
378 [label="Access variable R|<local>/y|"];
|
||||
379 [label="Access variable R|kotlin/String.length|"];
|
||||
380 [label="Access variable R|<local>/z|"];
|
||||
381 [label="Access variable R|kotlin/String.length|"];
|
||||
382 [label="Exit block"];
|
||||
}
|
||||
383 [label="Exit when branch result"];
|
||||
384 [label="Exit when"];
|
||||
}
|
||||
385 [label="Const: Null(null)"];
|
||||
386 [label="Assignment: R|<local>/y|"];
|
||||
subgraph cluster_81 {
|
||||
color=blue
|
||||
387 [label="Enter when"];
|
||||
subgraph cluster_82 {
|
||||
color=blue
|
||||
388 [label="Enter when branch condition "];
|
||||
389 [label="Access variable R|<local>/x|"];
|
||||
390 [label="Const: Null(null)"];
|
||||
391 [label="Equality operator !="];
|
||||
392 [label="Exit when branch condition"];
|
||||
}
|
||||
393 [label="Synthetic else branch"];
|
||||
394 [label="Enter when branch result"];
|
||||
subgraph cluster_83 {
|
||||
color=blue
|
||||
395 [label="Enter block"];
|
||||
396 [label="Access variable R|<local>/x|"];
|
||||
397 [label="Access variable R|kotlin/String.length|"];
|
||||
398 [label="Access variable R|<local>/y|"];
|
||||
399 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
|
||||
400 [label="Access variable R|<local>/z|"];
|
||||
401 [label="Access variable R|kotlin/String.length|"];
|
||||
402 [label="Exit block"];
|
||||
}
|
||||
403 [label="Exit when branch result"];
|
||||
404 [label="Exit when"];
|
||||
}
|
||||
subgraph cluster_84 {
|
||||
color=blue
|
||||
405 [label="Enter when"];
|
||||
subgraph cluster_85 {
|
||||
color=blue
|
||||
406 [label="Enter when branch condition "];
|
||||
407 [label="Access variable R|<local>/y|"];
|
||||
408 [label="Const: Null(null)"];
|
||||
409 [label="Equality operator !="];
|
||||
410 [label="Exit when branch condition"];
|
||||
}
|
||||
411 [label="Synthetic else branch"];
|
||||
412 [label="Enter when branch result"];
|
||||
subgraph cluster_86 {
|
||||
color=blue
|
||||
413 [label="Enter block"];
|
||||
414 [label="Access variable R|<local>/x|"];
|
||||
415 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
|
||||
416 [label="Access variable R|<local>/y|"];
|
||||
417 [label="Stub" style="filled" fillcolor=gray];
|
||||
418 [label="Access variable R|kotlin/String.length|" style="filled" fillcolor=gray];
|
||||
419 [label="Access variable R|<local>/z|" style="filled" fillcolor=gray];
|
||||
420 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#" style="filled" fillcolor=gray];
|
||||
421 [label="Exit block" style="filled" fillcolor=gray];
|
||||
}
|
||||
422 [label="Exit when branch result" style="filled" fillcolor=gray];
|
||||
423 [label="Exit when"];
|
||||
}
|
||||
subgraph cluster_87 {
|
||||
color=blue
|
||||
424 [label="Enter when"];
|
||||
subgraph cluster_88 {
|
||||
color=blue
|
||||
425 [label="Enter when branch condition "];
|
||||
426 [label="Access variable R|<local>/z|"];
|
||||
427 [label="Const: Null(null)"];
|
||||
428 [label="Equality operator !="];
|
||||
429 [label="Exit when branch condition"];
|
||||
}
|
||||
430 [label="Synthetic else branch"];
|
||||
431 [label="Enter when branch result"];
|
||||
subgraph cluster_89 {
|
||||
color=blue
|
||||
432 [label="Enter block"];
|
||||
433 [label="Access variable R|<local>/x|"];
|
||||
434 [label="Access variable R|kotlin/String.length|"];
|
||||
435 [label="Access variable R|<local>/y|"];
|
||||
436 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
|
||||
437 [label="Access variable R|<local>/z|"];
|
||||
438 [label="Access variable R|kotlin/String.length|"];
|
||||
439 [label="Exit block"];
|
||||
}
|
||||
440 [label="Exit when branch result"];
|
||||
441 [label="Exit when"];
|
||||
}
|
||||
442 [label="Exit block"];
|
||||
}
|
||||
443 [label="Exit function test_8" style="filled" fillcolor=red];
|
||||
}
|
||||
323 -> {324};
|
||||
324 -> {325};
|
||||
325 -> {326};
|
||||
326 -> {327};
|
||||
327 -> {328};
|
||||
328 -> {329};
|
||||
329 -> {330};
|
||||
330 -> {331};
|
||||
331 -> {332};
|
||||
332 -> {333};
|
||||
333 -> {334};
|
||||
334 -> {335};
|
||||
335 -> {336};
|
||||
336 -> {338 337};
|
||||
337 -> {348};
|
||||
338 -> {339};
|
||||
339 -> {340};
|
||||
340 -> {341};
|
||||
341 -> {342};
|
||||
342 -> {343};
|
||||
343 -> {344};
|
||||
344 -> {345};
|
||||
345 -> {346};
|
||||
346 -> {347};
|
||||
347 -> {348};
|
||||
348 -> {349};
|
||||
349 -> {350};
|
||||
350 -> {351};
|
||||
351 -> {352};
|
||||
352 -> {353};
|
||||
353 -> {354};
|
||||
354 -> {356 355};
|
||||
355 -> {366};
|
||||
356 -> {357};
|
||||
357 -> {358};
|
||||
358 -> {359};
|
||||
359 -> {360};
|
||||
360 -> {361};
|
||||
361 -> {362};
|
||||
362 -> {363};
|
||||
363 -> {364};
|
||||
364 -> {365};
|
||||
365 -> {366};
|
||||
366 -> {367};
|
||||
367 -> {368};
|
||||
368 -> {369};
|
||||
369 -> {370};
|
||||
370 -> {371};
|
||||
371 -> {372};
|
||||
372 -> {374 373};
|
||||
373 -> {384};
|
||||
374 -> {375};
|
||||
375 -> {376};
|
||||
376 -> {377};
|
||||
377 -> {378};
|
||||
378 -> {379};
|
||||
379 -> {380};
|
||||
380 -> {381};
|
||||
381 -> {382};
|
||||
382 -> {383};
|
||||
383 -> {384};
|
||||
384 -> {385};
|
||||
385 -> {386};
|
||||
386 -> {387};
|
||||
387 -> {388};
|
||||
388 -> {389};
|
||||
389 -> {390};
|
||||
390 -> {391};
|
||||
391 -> {392};
|
||||
392 -> {394 393};
|
||||
393 -> {404};
|
||||
394 -> {395};
|
||||
395 -> {396};
|
||||
396 -> {397};
|
||||
397 -> {398};
|
||||
398 -> {399};
|
||||
399 -> {400};
|
||||
400 -> {401};
|
||||
401 -> {402};
|
||||
402 -> {403};
|
||||
403 -> {404};
|
||||
404 -> {405};
|
||||
405 -> {406};
|
||||
406 -> {407};
|
||||
407 -> {408};
|
||||
408 -> {409};
|
||||
409 -> {410};
|
||||
410 -> {412 411};
|
||||
411 -> {423};
|
||||
412 -> {413};
|
||||
413 -> {414};
|
||||
414 -> {415};
|
||||
415 -> {416};
|
||||
416 -> {443} [label=onUncaughtException];
|
||||
416 -> {417} [style=dotted];
|
||||
417 -> {418} [style=dotted];
|
||||
418 -> {419} [style=dotted];
|
||||
419 -> {420} [style=dotted];
|
||||
420 -> {421} [style=dotted];
|
||||
421 -> {422} [style=dotted];
|
||||
422 -> {423} [style=dotted];
|
||||
423 -> {424};
|
||||
424 -> {425};
|
||||
425 -> {426};
|
||||
426 -> {427};
|
||||
427 -> {428};
|
||||
428 -> {429};
|
||||
429 -> {431 430};
|
||||
430 -> {441};
|
||||
431 -> {432};
|
||||
432 -> {433};
|
||||
433 -> {434};
|
||||
434 -> {435};
|
||||
435 -> {436};
|
||||
436 -> {437};
|
||||
437 -> {438};
|
||||
438 -> {439};
|
||||
439 -> {440};
|
||||
440 -> {441};
|
||||
441 -> {442};
|
||||
442 -> {443};
|
||||
|
||||
}
|
||||
|
||||
+54
@@ -104,6 +104,60 @@ FILE: boundSmartcastsInBranches.kt
|
||||
R|<local>/x|.R|/A.s|
|
||||
}
|
||||
public final fun test_7(): R|kotlin/Unit| {
|
||||
lval z: R|kotlin/String?| = Null(null)
|
||||
lvar y: R|kotlin/String?| = R|<local>/z|
|
||||
lval x: R|kotlin/String?| = R|<local>/y|
|
||||
when () {
|
||||
!=(R|<local>/x|, Null(null)) -> {
|
||||
R|<local>/x|.R|kotlin/String.length|
|
||||
R|<local>/y|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||
R|<local>/z|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||
}
|
||||
}
|
||||
|
||||
when () {
|
||||
!=(R|<local>/y|, Null(null)) -> {
|
||||
R|<local>/x|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||
R|<local>/y|.R|kotlin/String.length|
|
||||
R|<local>/z|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||
}
|
||||
}
|
||||
|
||||
when () {
|
||||
!=(R|<local>/z|, Null(null)) -> {
|
||||
R|<local>/x|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||
R|<local>/y|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||
R|<local>/z|.R|kotlin/String.length|
|
||||
}
|
||||
}
|
||||
|
||||
R|<local>/y| = Null(null)
|
||||
when () {
|
||||
!=(R|<local>/x|, Null(null)) -> {
|
||||
R|<local>/x|.R|kotlin/String.length|
|
||||
R|<local>/y|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||
R|<local>/z|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||
}
|
||||
}
|
||||
|
||||
when () {
|
||||
!=(R|<local>/y|, Null(null)) -> {
|
||||
R|<local>/x|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||
R|<local>/y|.R|kotlin/String.length|
|
||||
R|<local>/z|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||
}
|
||||
}
|
||||
|
||||
when () {
|
||||
!=(R|<local>/z|, Null(null)) -> {
|
||||
R|<local>/x|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||
R|<local>/y|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||
R|<local>/z|.R|kotlin/String.length|
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test_8(): R|kotlin/Unit| {
|
||||
lval z: R|kotlin/String?| = Null(null)
|
||||
lvar y: R|kotlin/String?| = R|<local>/z|
|
||||
lval x: R|kotlin/String?| = R|<local>/y|
|
||||
|
||||
compiler/fir/analysis-tests/testData/resolve/smartcasts/boundSmartcasts/boundSmartcastsInBranches.kt
Vendored
+42
@@ -83,6 +83,48 @@ fun test_7() {
|
||||
var y : String? = z
|
||||
val x: String? = y
|
||||
|
||||
if (x != null) {
|
||||
x.length // OK
|
||||
y<!UNSAFE_CALL!>.<!>length // Bad
|
||||
z<!UNSAFE_CALL!>.<!>length // Bad
|
||||
}
|
||||
if (y != null) {
|
||||
x<!UNSAFE_CALL!>.<!>length // Bad
|
||||
y.length // OK
|
||||
z<!UNSAFE_CALL!>.<!>length // Bad
|
||||
}
|
||||
|
||||
if (z != null) {
|
||||
x<!UNSAFE_CALL!>.<!>length // Bad
|
||||
y<!UNSAFE_CALL!>.<!>length // Bad
|
||||
z.length // OK
|
||||
}
|
||||
|
||||
y = null
|
||||
|
||||
if (x != null) {
|
||||
x.length // OK
|
||||
y<!UNSAFE_CALL!>.<!>length // Bad
|
||||
z<!UNSAFE_CALL!>.<!>length // Bad
|
||||
}
|
||||
if (<!SENSELESS_COMPARISON!>y != null<!>) {
|
||||
x<!UNSAFE_CALL!>.<!>length // Bad
|
||||
y.length // OK
|
||||
z<!UNSAFE_CALL!>.<!>length // Bad
|
||||
}
|
||||
|
||||
if (z != null) {
|
||||
x<!UNSAFE_CALL!>.<!>length // Bad
|
||||
y<!UNSAFE_CALL!>.<!>length // Bad
|
||||
z.length // OK
|
||||
}
|
||||
}
|
||||
|
||||
fun test_8() {
|
||||
val z: String? = null
|
||||
var y = z
|
||||
val x = y
|
||||
|
||||
if (x != null) {
|
||||
x.length // OK
|
||||
y.length // OK
|
||||
|
||||
Reference in New Issue
Block a user