FIR CFG: join/unify data flow from postponed lambdas at each level
For example:
foo(
// `if` joins A & B
if (condition)
run { ... } // A
else
run { ... }, // B
run { ... } // C
) // `foo` unifies `A & B` and `C`, so if it is not resolved itself,
// further `if`s, `when`s, safe calls outside it, etc. continue
// building the correct type predicate until the next completed
// call.
^KT-44512 Fixed
This commit is contained in:
+360
-351
File diff suppressed because it is too large
Load Diff
+5
-5
@@ -28,7 +28,7 @@ FILE: flowFromInplaceLambda2.kt
|
|||||||
^ R|/n|<R|kotlin/Nothing?|>()
|
^ R|/n|<R|kotlin/Nothing?|>()
|
||||||
}
|
}
|
||||||
)), R|/someCompletedCall|(Int(1)), R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=EXACTLY_ONCE> {
|
)), R|/someCompletedCall|(Int(1)), R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=EXACTLY_ONCE> {
|
||||||
R|<local>/x|.R|kotlin/String.length|
|
R|<local>/x|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||||
^ Int(123)
|
^ Int(123)
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
@@ -52,7 +52,7 @@ FILE: flowFromInplaceLambda2.kt
|
|||||||
^ Int(123)
|
^ Int(123)
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
R|<local>/x|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
R|<local>/x|.R|kotlin/String.length|
|
||||||
}
|
}
|
||||||
public final fun test4(x: R|kotlin/String?|): R|kotlin/Unit| {
|
public final fun test4(x: R|kotlin/String?|): R|kotlin/Unit| {
|
||||||
lvar p: R|kotlin/String?| = R|<local>/x|
|
lvar p: R|kotlin/String?| = R|<local>/x|
|
||||||
@@ -74,11 +74,11 @@ FILE: flowFromInplaceLambda2.kt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
), Int(1), R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=EXACTLY_ONCE> {
|
), Int(1), R|kotlin/run|<R|kotlin/Int|>(<L> = run@fun <anonymous>(): R|kotlin/Int| <inline=Inline, kind=EXACTLY_ONCE> {
|
||||||
R|<local>/p|.R|kotlin/String.length|
|
R|<local>/p|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||||
^ Int(123)
|
^ Int(123)
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
R|<local>/p|.R|kotlin/String.length|
|
R|<local>/p|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ FILE: flowFromInplaceLambda2.kt
|
|||||||
^ String()
|
^ String()
|
||||||
}
|
}
|
||||||
))
|
))
|
||||||
R|<local>/x|.R|kotlin/String.length|
|
R|<local>/x|.<Inapplicable(UNSAFE_CALL): kotlin/String.length>#
|
||||||
}
|
}
|
||||||
public final fun test6(x: R|kotlin/String?|): R|kotlin/Unit| {
|
public final fun test6(x: R|kotlin/String?|): R|kotlin/Unit| {
|
||||||
R|/foo|<R|kotlin/Int|>(R|/id|<R|kotlin/Nothing?|>(when () {
|
R|/foo|<R|kotlin/Int|>(R|/id|<R|kotlin/Nothing?|>(when () {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ fun test2(x: String?) {
|
|||||||
foo(
|
foo(
|
||||||
id(run { x as String; n() }),
|
id(run { x as String; n() }),
|
||||||
someCompletedCall(1),
|
someCompletedCall(1),
|
||||||
run { x.length; 123 } // Bad (resolution order undefined)
|
run { x<!UNSAFE_CALL!>.<!>length; 123 } // Bad (resolution order undefined)
|
||||||
)
|
)
|
||||||
x.length // OK (x as String unconditional)
|
x.length // OK (x as String unconditional)
|
||||||
}
|
}
|
||||||
@@ -32,7 +32,7 @@ fun test3(x: String?) {
|
|||||||
if (true) 1 else 2,
|
if (true) 1 else 2,
|
||||||
run { x<!UNSAFE_CALL!>.<!>length; 123 } // Bad (resolution order undefined)
|
run { x<!UNSAFE_CALL!>.<!>length; 123 } // Bad (resolution order undefined)
|
||||||
)
|
)
|
||||||
x<!UNSAFE_CALL!>.<!>length // OK (x as String unconditional)
|
x.length // OK (x as String unconditional)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test4(x: String?) {
|
fun test4(x: String?) {
|
||||||
@@ -41,9 +41,9 @@ fun test4(x: String?) {
|
|||||||
foo(
|
foo(
|
||||||
id(if (true) run { p = null; n() } else run { n() }),
|
id(if (true) run { p = null; n() } else run { n() }),
|
||||||
1,
|
1,
|
||||||
run { p.length; 123 } // Bad (p = null possible)
|
run { p<!UNSAFE_CALL!>.<!>length; 123 } // Bad (p = null possible)
|
||||||
)
|
)
|
||||||
p.length // Bad (p = null possible)
|
p<!UNSAFE_CALL!>.<!>length // Bad (p = null possible)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ fun test5(x: String?, y: String?) {
|
|||||||
1,
|
1,
|
||||||
run { "" }
|
run { "" }
|
||||||
)
|
)
|
||||||
x.length // Bad (x as String conditional)
|
x<!UNSAFE_CALL!>.<!>length // Bad (x as String conditional)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test6(x: String?) {
|
fun test6(x: String?) {
|
||||||
|
|||||||
+73
-71
@@ -63,14 +63,14 @@ digraph inplaceLambdaInControlFlowExpressions_kt {
|
|||||||
24 [label="Postponed enter to lambda"];
|
24 [label="Postponed enter to lambda"];
|
||||||
subgraph cluster_9 {
|
subgraph cluster_9 {
|
||||||
color=blue
|
color=blue
|
||||||
33 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
34 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_10 {
|
subgraph cluster_10 {
|
||||||
color=blue
|
color=blue
|
||||||
34 [label="Enter block"];
|
35 [label="Enter block"];
|
||||||
35 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
|
36 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
|
||||||
36 [label="Exit block"];
|
37 [label="Exit block"];
|
||||||
}
|
}
|
||||||
37 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
38 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
25 [label="Postponed exit from lambda"];
|
25 [label="Postponed exit from lambda"];
|
||||||
26 [label="Function call: R|kotlin/run|<R|kotlin/String|>(...)"];
|
26 [label="Function call: R|kotlin/run|<R|kotlin/String|>(...)"];
|
||||||
@@ -84,6 +84,7 @@ digraph inplaceLambdaInControlFlowExpressions_kt {
|
|||||||
}
|
}
|
||||||
32 [label="Exit function test_1" style="filled" fillcolor=red];
|
32 [label="Exit function test_1" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
|
33 [label="Merge postponed lambda exits"];
|
||||||
9 -> {10};
|
9 -> {10};
|
||||||
10 -> {11};
|
10 -> {11};
|
||||||
11 -> {12};
|
11 -> {12};
|
||||||
@@ -99,89 +100,89 @@ digraph inplaceLambdaInControlFlowExpressions_kt {
|
|||||||
21 -> {29};
|
21 -> {29};
|
||||||
22 -> {23};
|
22 -> {23};
|
||||||
23 -> {24};
|
23 -> {24};
|
||||||
24 -> {33};
|
24 -> {34};
|
||||||
24 -> {25} [color=red];
|
24 -> {25} [color=red];
|
||||||
24 -> {33} [style=dashed];
|
24 -> {34} [style=dashed];
|
||||||
25 -> {26};
|
25 -> {26};
|
||||||
26 -> {27};
|
26 -> {27};
|
||||||
27 -> {28};
|
27 -> {28};
|
||||||
28 -> {29};
|
28 -> {29};
|
||||||
29 -> {30};
|
29 -> {33 30};
|
||||||
30 -> {31};
|
30 -> {31};
|
||||||
31 -> {32};
|
31 -> {32};
|
||||||
33 -> {34};
|
|
||||||
34 -> {35};
|
34 -> {35};
|
||||||
35 -> {36};
|
35 -> {36};
|
||||||
36 -> {37};
|
36 -> {37};
|
||||||
37 -> {25} [color=green];
|
37 -> {38};
|
||||||
|
38 -> {33} [color=red];
|
||||||
|
38 -> {25} [color=green];
|
||||||
|
|
||||||
subgraph cluster_11 {
|
subgraph cluster_11 {
|
||||||
color=red
|
color=red
|
||||||
38 [label="Enter function test_2" style="filled" fillcolor=red];
|
39 [label="Enter function test_2" style="filled" fillcolor=red];
|
||||||
subgraph cluster_12 {
|
subgraph cluster_12 {
|
||||||
color=blue
|
color=blue
|
||||||
39 [label="Enter block"];
|
40 [label="Enter block"];
|
||||||
subgraph cluster_13 {
|
subgraph cluster_13 {
|
||||||
color=blue
|
color=blue
|
||||||
40 [label="Try expression enter"];
|
41 [label="Try expression enter"];
|
||||||
subgraph cluster_14 {
|
subgraph cluster_14 {
|
||||||
color=blue
|
color=blue
|
||||||
41 [label="Try main block enter"];
|
42 [label="Try main block enter"];
|
||||||
subgraph cluster_15 {
|
subgraph cluster_15 {
|
||||||
color=blue
|
color=blue
|
||||||
42 [label="Enter block"];
|
43 [label="Enter block"];
|
||||||
43 [label="Postponed enter to lambda"];
|
44 [label="Postponed enter to lambda"];
|
||||||
subgraph cluster_16 {
|
subgraph cluster_16 {
|
||||||
color=blue
|
color=blue
|
||||||
58 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
59 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_17 {
|
subgraph cluster_17 {
|
||||||
color=blue
|
color=blue
|
||||||
59 [label="Enter block"];
|
60 [label="Enter block"];
|
||||||
60 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
|
61 [label="Function call: R|/materialize|<R|kotlin/String|>()"];
|
||||||
61 [label="Exit block"];
|
62 [label="Exit block"];
|
||||||
}
|
}
|
||||||
62 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
63 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
44 [label="Postponed exit from lambda"];
|
45 [label="Postponed exit from lambda"];
|
||||||
45 [label="Function call: R|kotlin/run|<R|kotlin/String|>(...)"];
|
46 [label="Function call: R|kotlin/run|<R|kotlin/String|>(...)"];
|
||||||
46 [label="Exit block"];
|
47 [label="Exit block"];
|
||||||
}
|
}
|
||||||
47 [label="Try main block exit"];
|
48 [label="Try main block exit"];
|
||||||
}
|
}
|
||||||
subgraph cluster_18 {
|
subgraph cluster_18 {
|
||||||
color=blue
|
color=blue
|
||||||
48 [label="Catch enter"];
|
49 [label="Catch enter"];
|
||||||
subgraph cluster_19 {
|
subgraph cluster_19 {
|
||||||
color=blue
|
color=blue
|
||||||
49 [label="Enter block"];
|
50 [label="Enter block"];
|
||||||
50 [label="Const: String()"];
|
51 [label="Const: String()"];
|
||||||
51 [label="Exit block"];
|
52 [label="Exit block"];
|
||||||
}
|
}
|
||||||
52 [label="Catch exit"];
|
53 [label="Catch exit"];
|
||||||
}
|
}
|
||||||
53 [label="Try expression exit"];
|
54 [label="Try expression exit"];
|
||||||
}
|
}
|
||||||
54 [label="Call arguments union" style="filled" fillcolor=yellow];
|
55 [label="Call arguments union" style="filled" fillcolor=yellow];
|
||||||
55 [label="Variable declaration: lval x: R|kotlin/String|"];
|
56 [label="Variable declaration: lval x: R|kotlin/String|"];
|
||||||
56 [label="Exit block"];
|
57 [label="Exit block"];
|
||||||
}
|
}
|
||||||
57 [label="Exit function test_2" style="filled" fillcolor=red];
|
58 [label="Exit function test_2" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
38 -> {39};
|
|
||||||
39 -> {40};
|
39 -> {40};
|
||||||
40 -> {41 48};
|
40 -> {41};
|
||||||
41 -> {42};
|
41 -> {42 49};
|
||||||
42 -> {43};
|
42 -> {43};
|
||||||
43 -> {58};
|
43 -> {44};
|
||||||
43 -> {44} [color=red];
|
44 -> {59};
|
||||||
43 -> {58} [style=dashed];
|
44 -> {45} [color=red];
|
||||||
44 -> {45};
|
44 -> {59} [style=dashed];
|
||||||
45 -> {46};
|
45 -> {46};
|
||||||
46 -> {47};
|
46 -> {47};
|
||||||
47 -> {53 48};
|
47 -> {48};
|
||||||
48 -> {49};
|
48 -> {54 49};
|
||||||
48 -> {57} [label=onUncaughtException];
|
|
||||||
49 -> {50};
|
49 -> {50};
|
||||||
|
49 -> {58} [label=onUncaughtException];
|
||||||
50 -> {51};
|
50 -> {51};
|
||||||
51 -> {52};
|
51 -> {52};
|
||||||
52 -> {53};
|
52 -> {53};
|
||||||
@@ -189,56 +190,57 @@ digraph inplaceLambdaInControlFlowExpressions_kt {
|
|||||||
54 -> {55};
|
54 -> {55};
|
||||||
55 -> {56};
|
55 -> {56};
|
||||||
56 -> {57};
|
56 -> {57};
|
||||||
58 -> {59};
|
57 -> {58};
|
||||||
59 -> {60};
|
59 -> {60};
|
||||||
60 -> {61};
|
60 -> {61};
|
||||||
61 -> {62};
|
61 -> {62};
|
||||||
62 -> {54} [color=red];
|
62 -> {63};
|
||||||
62 -> {44} [color=green];
|
63 -> {55} [color=red];
|
||||||
|
63 -> {45} [color=green];
|
||||||
|
|
||||||
subgraph cluster_20 {
|
subgraph cluster_20 {
|
||||||
color=red
|
color=red
|
||||||
63 [label="Enter function test_3" style="filled" fillcolor=red];
|
64 [label="Enter function test_3" style="filled" fillcolor=red];
|
||||||
subgraph cluster_21 {
|
subgraph cluster_21 {
|
||||||
color=blue
|
color=blue
|
||||||
64 [label="Enter block"];
|
65 [label="Enter block"];
|
||||||
65 [label="Postponed enter to lambda"];
|
66 [label="Postponed enter to lambda"];
|
||||||
subgraph cluster_22 {
|
subgraph cluster_22 {
|
||||||
color=blue
|
color=blue
|
||||||
73 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
74 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_23 {
|
subgraph cluster_23 {
|
||||||
color=blue
|
color=blue
|
||||||
74 [label="Enter block"];
|
75 [label="Enter block"];
|
||||||
75 [label="Function call: R|/materialize|<R|kotlin/String?|>()"];
|
76 [label="Function call: R|/materialize|<R|kotlin/String?|>()"];
|
||||||
76 [label="Exit block"];
|
77 [label="Exit block"];
|
||||||
}
|
}
|
||||||
77 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
78 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
66 [label="Postponed exit from lambda"];
|
67 [label="Postponed exit from lambda"];
|
||||||
67 [label="Function call: R|kotlin/run|<R|kotlin/String?|>(...)"];
|
68 [label="Function call: R|kotlin/run|<R|kotlin/String?|>(...)"];
|
||||||
68 [label="Check not null: R|kotlin/run|<R|kotlin/String?|>(...)!!"];
|
69 [label="Check not null: R|kotlin/run|<R|kotlin/String?|>(...)!!"];
|
||||||
69 [label="Call arguments union" style="filled" fillcolor=yellow];
|
70 [label="Call arguments union" style="filled" fillcolor=yellow];
|
||||||
70 [label="Variable declaration: lval x: R|kotlin/String|"];
|
71 [label="Variable declaration: lval x: R|kotlin/String|"];
|
||||||
71 [label="Exit block"];
|
72 [label="Exit block"];
|
||||||
}
|
}
|
||||||
72 [label="Exit function test_3" style="filled" fillcolor=red];
|
73 [label="Exit function test_3" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
63 -> {64};
|
|
||||||
64 -> {65};
|
64 -> {65};
|
||||||
65 -> {73};
|
65 -> {66};
|
||||||
65 -> {66} [color=red];
|
66 -> {74};
|
||||||
65 -> {73} [style=dashed];
|
66 -> {67} [color=red];
|
||||||
66 -> {67};
|
66 -> {74} [style=dashed];
|
||||||
67 -> {68};
|
67 -> {68};
|
||||||
68 -> {69};
|
68 -> {69};
|
||||||
69 -> {70};
|
69 -> {70};
|
||||||
70 -> {71};
|
70 -> {71};
|
||||||
71 -> {72};
|
71 -> {72};
|
||||||
73 -> {74};
|
72 -> {73};
|
||||||
74 -> {75};
|
74 -> {75};
|
||||||
75 -> {76};
|
75 -> {76};
|
||||||
76 -> {77};
|
76 -> {77};
|
||||||
77 -> {69} [color=red];
|
77 -> {78};
|
||||||
77 -> {66} [color=green];
|
78 -> {70} [color=red];
|
||||||
|
78 -> {67} [color=green];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-14
@@ -69,16 +69,16 @@ digraph incorrectSmartcastToNothing_kt {
|
|||||||
33 [label="Postponed enter to lambda"];
|
33 [label="Postponed enter to lambda"];
|
||||||
subgraph cluster_10 {
|
subgraph cluster_10 {
|
||||||
color=blue
|
color=blue
|
||||||
43 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
45 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_11 {
|
subgraph cluster_11 {
|
||||||
color=blue
|
color=blue
|
||||||
44 [label="Enter block"];
|
46 [label="Enter block"];
|
||||||
45 [label="Access variable R|<local>/it|"];
|
47 [label="Access variable R|<local>/it|"];
|
||||||
46 [label="Const: String(main.kts.compiled.cache)"];
|
48 [label="Const: String(main.kts.compiled.cache)"];
|
||||||
47 [label="Function call: R|java/io/File.File|(...)"];
|
49 [label="Function call: R|java/io/File.File|(...)"];
|
||||||
48 [label="Exit block"];
|
50 [label="Exit block"];
|
||||||
}
|
}
|
||||||
49 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
51 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
34 [label="Postponed exit from lambda"];
|
34 [label="Postponed exit from lambda"];
|
||||||
35 [label="Function call: $subj$.R|kotlin/let|<R|java/io/File|, R|java/io/File|>(...)"];
|
35 [label="Function call: $subj$.R|kotlin/let|<R|java/io/File|, R|java/io/File|>(...)"];
|
||||||
@@ -93,6 +93,8 @@ digraph incorrectSmartcastToNothing_kt {
|
|||||||
}
|
}
|
||||||
42 [label="Exit function test" style="filled" fillcolor=red];
|
42 [label="Exit function test" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
|
43 [label="Merge postponed lambda exits"];
|
||||||
|
44 [label="Merge postponed lambda exits"];
|
||||||
4 -> {5};
|
4 -> {5};
|
||||||
5 -> {6};
|
5 -> {6};
|
||||||
6 -> {7};
|
6 -> {7};
|
||||||
@@ -122,23 +124,25 @@ digraph incorrectSmartcastToNothing_kt {
|
|||||||
30 -> {31};
|
30 -> {31};
|
||||||
31 -> {32 36};
|
31 -> {32 36};
|
||||||
32 -> {33};
|
32 -> {33};
|
||||||
33 -> {43};
|
33 -> {45};
|
||||||
33 -> {34} [color=red];
|
33 -> {34} [color=red];
|
||||||
33 -> {43} [style=dashed];
|
33 -> {45} [style=dashed];
|
||||||
34 -> {35};
|
34 -> {35};
|
||||||
35 -> {36};
|
35 -> {36};
|
||||||
36 -> {37};
|
36 -> {43 37};
|
||||||
37 -> {38};
|
37 -> {38};
|
||||||
38 -> {39};
|
38 -> {39};
|
||||||
39 -> {40};
|
39 -> {44 40};
|
||||||
40 -> {41};
|
40 -> {41};
|
||||||
41 -> {42};
|
41 -> {42};
|
||||||
43 -> {44};
|
43 -> {44} [color=red];
|
||||||
44 -> {45};
|
|
||||||
45 -> {46};
|
45 -> {46};
|
||||||
46 -> {47};
|
46 -> {47};
|
||||||
47 -> {48};
|
47 -> {48};
|
||||||
48 -> {49};
|
48 -> {49};
|
||||||
49 -> {34} [color=green];
|
49 -> {50};
|
||||||
|
50 -> {51};
|
||||||
|
51 -> {43} [color=red];
|
||||||
|
51 -> {34} [color=green];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-10
@@ -135,14 +135,14 @@ digraph lambdaInWhenBranch_kt {
|
|||||||
48 [label="Postponed enter to lambda"];
|
48 [label="Postponed enter to lambda"];
|
||||||
subgraph cluster_18 {
|
subgraph cluster_18 {
|
||||||
color=blue
|
color=blue
|
||||||
81 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
82 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
|
||||||
subgraph cluster_19 {
|
subgraph cluster_19 {
|
||||||
color=blue
|
color=blue
|
||||||
82 [label="Enter block"];
|
83 [label="Enter block"];
|
||||||
83 [label="Access variable R|<local>/it|"];
|
84 [label="Access variable R|<local>/it|"];
|
||||||
84 [label="Exit block"];
|
85 [label="Exit block"];
|
||||||
}
|
}
|
||||||
85 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
86 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
49 [label="Postponed exit from lambda"];
|
49 [label="Postponed exit from lambda"];
|
||||||
50 [label="Function call: String().R|kotlin/let|<R|kotlin/String|, R|kotlin/String|>(...)"];
|
50 [label="Function call: String().R|kotlin/let|<R|kotlin/String|, R|kotlin/String|>(...)"];
|
||||||
@@ -195,6 +195,7 @@ digraph lambdaInWhenBranch_kt {
|
|||||||
}
|
}
|
||||||
80 [label="Exit function foo" style="filled" fillcolor=red];
|
80 [label="Exit function foo" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
|
81 [label="Merge postponed lambda exits"];
|
||||||
28 -> {29};
|
28 -> {29};
|
||||||
29 -> {30};
|
29 -> {30};
|
||||||
30 -> {31};
|
30 -> {31};
|
||||||
@@ -215,14 +216,14 @@ digraph lambdaInWhenBranch_kt {
|
|||||||
45 -> {46};
|
45 -> {46};
|
||||||
46 -> {47};
|
46 -> {47};
|
||||||
47 -> {48};
|
47 -> {48};
|
||||||
48 -> {81};
|
48 -> {82};
|
||||||
48 -> {49} [color=red];
|
48 -> {49} [color=red];
|
||||||
48 -> {81} [style=dashed];
|
48 -> {82} [style=dashed];
|
||||||
49 -> {50};
|
49 -> {50};
|
||||||
50 -> {51};
|
50 -> {51};
|
||||||
51 -> {52};
|
51 -> {52};
|
||||||
52 -> {53};
|
52 -> {53};
|
||||||
53 -> {54};
|
53 -> {81 54};
|
||||||
54 -> {55};
|
54 -> {55};
|
||||||
55 -> {56};
|
55 -> {56};
|
||||||
56 -> {57};
|
56 -> {57};
|
||||||
@@ -249,10 +250,11 @@ digraph lambdaInWhenBranch_kt {
|
|||||||
77 -> {78};
|
77 -> {78};
|
||||||
78 -> {79};
|
78 -> {79};
|
||||||
79 -> {80};
|
79 -> {80};
|
||||||
81 -> {82};
|
|
||||||
82 -> {83};
|
82 -> {83};
|
||||||
83 -> {84};
|
83 -> {84};
|
||||||
84 -> {85};
|
84 -> {85};
|
||||||
85 -> {49} [color=green];
|
85 -> {86};
|
||||||
|
86 -> {81} [color=red];
|
||||||
|
86 -> {49} [color=green];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-4
@@ -826,7 +826,7 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun exitWhenExpression(whenExpression: FirWhenExpression) {
|
fun exitWhenExpression(whenExpression: FirWhenExpression) {
|
||||||
val (whenExitNode, syntheticElseNode) = graphBuilder.exitWhenExpression(whenExpression)
|
val (whenExitNode, syntheticElseNode, mergePostponedLambdaExitsNode) = graphBuilder.exitWhenExpression(whenExpression)
|
||||||
if (syntheticElseNode != null) {
|
if (syntheticElseNode != null) {
|
||||||
val previousConditionExitNode = syntheticElseNode.firstPreviousNode as? WhenBranchConditionExitNode
|
val previousConditionExitNode = syntheticElseNode.firstPreviousNode as? WhenBranchConditionExitNode
|
||||||
// previous node for syntheticElseNode can be not WhenBranchConditionExitNode in case of `when` without any branches
|
// previous node for syntheticElseNode can be not WhenBranchConditionExitNode in case of `when` without any branches
|
||||||
@@ -844,6 +844,7 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
whenExitNode.mergeIncomingFlow()
|
whenExitNode.mergeIncomingFlow()
|
||||||
|
mergePostponedLambdaExitsNode?.mergeIncomingFlow()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exitWhenSubjectExpression(expression: FirWhenSubjectExpression) {
|
fun exitWhenSubjectExpression(expression: FirWhenSubjectExpression) {
|
||||||
@@ -1022,8 +1023,9 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun exitSafeCall(safeCall: FirSafeCallExpression) {
|
fun exitSafeCall(safeCall: FirSafeCallExpression) {
|
||||||
val node = graphBuilder.exitSafeCall().mergeIncomingFlow()
|
val (node, mergePostponedLambdaExitsNode) = graphBuilder.exitSafeCall()
|
||||||
val flow = node.flow
|
val flow = node.mergeIncomingFlow().flow
|
||||||
|
mergePostponedLambdaExitsNode?.mergeIncomingFlow()
|
||||||
|
|
||||||
val variable = variableStorage.getOrCreateVariable(flow, safeCall)
|
val variable = variableStorage.getOrCreateVariable(flow, safeCall)
|
||||||
val receiverVariable = when (variable) {
|
val receiverVariable = when (variable) {
|
||||||
@@ -1462,7 +1464,9 @@ abstract class FirDataFlowAnalyzer<FLOW : Flow>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun exitElvis(elvisExpression: FirElvisExpression, isLhsNotNull: Boolean) {
|
fun exitElvis(elvisExpression: FirElvisExpression, isLhsNotNull: Boolean) {
|
||||||
val node = graphBuilder.exitElvis().mergeIncomingFlow()
|
val (node, mergePostponedLambdaExitsNode) = graphBuilder.exitElvis()
|
||||||
|
node.mergeIncomingFlow()
|
||||||
|
mergePostponedLambdaExitsNode?.mergeIncomingFlow()
|
||||||
if (isLhsNotNull) {
|
if (isLhsNotNull) {
|
||||||
elvisExpression.lhs.propagateNotNullInfo(node)
|
elvisExpression.lhs.propagateNotNullInfo(node)
|
||||||
}
|
}
|
||||||
|
|||||||
+93
-46
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.fir.types.*
|
|||||||
import org.jetbrains.kotlin.fir.util.ListMultimap
|
import org.jetbrains.kotlin.fir.util.ListMultimap
|
||||||
import org.jetbrains.kotlin.fir.util.listMultimapOf
|
import org.jetbrains.kotlin.fir.util.listMultimapOf
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor
|
import org.jetbrains.kotlin.fir.visitors.FirDefaultVisitor
|
||||||
|
import org.jetbrains.kotlin.utils.addToStdlib.popLast
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
import org.jetbrains.kotlin.utils.addToStdlib.runIf
|
||||||
import kotlin.random.Random
|
import kotlin.random.Random
|
||||||
|
|
||||||
@@ -85,7 +86,7 @@ class ControlFlowGraphBuilder {
|
|||||||
private val loopEnterNodes: NodeStorage<FirElement, CFGNode<FirElement>> = NodeStorage()
|
private val loopEnterNodes: NodeStorage<FirElement, CFGNode<FirElement>> = NodeStorage()
|
||||||
private val loopExitNodes: NodeStorage<FirLoop, LoopExitNode> = NodeStorage()
|
private val loopExitNodes: NodeStorage<FirLoop, LoopExitNode> = NodeStorage()
|
||||||
|
|
||||||
private val exitsFromCompletedPostponedAnonymousFunctions: MutableList<PostponedLambdaExitNode> = mutableListOf()
|
private val exitsFromCompletedPostponedAnonymousFunctions: MutableList<MutableList<CFGNode<*>>> = mutableListOf()
|
||||||
|
|
||||||
private val whenExitNodes: NodeStorage<FirWhenExpression, WhenExitNode> = NodeStorage()
|
private val whenExitNodes: NodeStorage<FirWhenExpression, WhenExitNode> = NodeStorage()
|
||||||
private val whenBranchIndices: Stack<Map<FirWhenBranch, Int>> = stackOf()
|
private val whenBranchIndices: Stack<Map<FirWhenBranch, Int>> = stackOf()
|
||||||
@@ -341,7 +342,8 @@ class ControlFlowGraphBuilder {
|
|||||||
val graph = popGraph().also { graph ->
|
val graph = popGraph().also { graph ->
|
||||||
assert(graph.declaration == anonymousFunction)
|
assert(graph.declaration == anonymousFunction)
|
||||||
assert(graph.exitNode == exitNode)
|
assert(graph.exitNode == exitNode)
|
||||||
exitsFromCompletedPostponedAnonymousFunctions.removeAll { it.owner == graph }
|
// TODO: disregarding the edges is probably not correct, though this should never find any nodes anyway
|
||||||
|
exitsFromCompletedPostponedAnonymousFunctions.lastOrNull()?.removeAll { it.owner == graph }
|
||||||
}
|
}
|
||||||
|
|
||||||
val postponedEnterNode = entersToPostponedAnonymousFunctions.remove(symbol)!!
|
val postponedEnterNode = entersToPostponedAnonymousFunctions.remove(symbol)!!
|
||||||
@@ -361,7 +363,7 @@ class ControlFlowGraphBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (invocationKind == EventOccurrencesRange.EXACTLY_ONCE && shouldPassFlowFromInplaceLambda.top()) {
|
if (invocationKind == EventOccurrencesRange.EXACTLY_ONCE && shouldPassFlowFromInplaceLambda.top()) {
|
||||||
exitsFromCompletedPostponedAnonymousFunctions += postponedExitNode
|
exitsFromCompletedPostponedAnonymousFunctions.lastOrNull()?.add(postponedExitNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
val containingGraph = parentGraphForAnonymousFunctions.remove(symbol) ?: currentGraph
|
val containingGraph = parentGraphForAnonymousFunctions.remove(symbol) ?: currentGraph
|
||||||
@@ -666,6 +668,7 @@ class ControlFlowGraphBuilder {
|
|||||||
whenBranchIndices.push(whenExpression.branches.mapIndexed { index, branch -> branch to index }.toMap())
|
whenBranchIndices.push(whenExpression.branches.mapIndexed { index, branch -> branch to index }.toMap())
|
||||||
notCompletedFunctionCalls.push(mutableListOf())
|
notCompletedFunctionCalls.push(mutableListOf())
|
||||||
levelCounter++
|
levelCounter++
|
||||||
|
splitDataFlowForPostponedLambdas()
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,7 +699,9 @@ class ControlFlowGraphBuilder {
|
|||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exitWhenExpression(whenExpression: FirWhenExpression): Pair<WhenExitNode, WhenSyntheticElseBranchNode?> {
|
fun exitWhenExpression(
|
||||||
|
whenExpression: FirWhenExpression
|
||||||
|
): Triple<WhenExitNode, WhenSyntheticElseBranchNode?, MergePostponedLambdaExitsNode?> {
|
||||||
val whenExitNode = whenExitNodes.pop()
|
val whenExitNode = whenExitNodes.pop()
|
||||||
// exit from last condition node still on stack
|
// exit from last condition node still on stack
|
||||||
// we should remove it
|
// we should remove it
|
||||||
@@ -710,10 +715,9 @@ class ControlFlowGraphBuilder {
|
|||||||
} else null
|
} else null
|
||||||
whenExitNode.updateDeadStatus()
|
whenExitNode.updateDeadStatus()
|
||||||
lastNodes.push(whenExitNode)
|
lastNodes.push(whenExitNode)
|
||||||
dropPostponedLambdasForNonDeterministicCalls()
|
|
||||||
levelCounter--
|
levelCounter--
|
||||||
whenBranchIndices.pop()
|
whenBranchIndices.pop()
|
||||||
return whenExitNode to syntheticElseBranchNode
|
return Triple(whenExitNode, syntheticElseBranchNode, joinDataFlowFromPostponedLambdasWith(whenExitNode))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------- While Loop -----------------------------------
|
// ----------------------------------- While Loop -----------------------------------
|
||||||
@@ -920,6 +924,7 @@ class ControlFlowGraphBuilder {
|
|||||||
finallyExitNodes.push(createFinallyBlockExitNode(tryExpression))
|
finallyExitNodes.push(createFinallyBlockExitNode(tryExpression))
|
||||||
}
|
}
|
||||||
notCompletedFunctionCalls.push(mutableListOf())
|
notCompletedFunctionCalls.push(mutableListOf())
|
||||||
|
splitDataFlowForPostponedLambdas()
|
||||||
return enterTryExpressionNode to enterTryNodeBlock
|
return enterTryExpressionNode to enterTryNodeBlock
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1074,6 +1079,7 @@ class ControlFlowGraphBuilder {
|
|||||||
|
|
||||||
fun enterCall() {
|
fun enterCall() {
|
||||||
levelCounter++
|
levelCounter++
|
||||||
|
splitDataFlowForPostponedLambdas()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exitIgnoredCall(functionCall: FirFunctionCall) {
|
fun exitIgnoredCall(functionCall: FirFunctionCall) {
|
||||||
@@ -1151,53 +1157,92 @@ class ControlFlowGraphBuilder {
|
|||||||
return node to unionNode
|
return node to unionNode
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// Arguments are evaluated left to right, and this is how data flows.
|
||||||
* This is needed for some control flow constructions which are resolved as calls (when and elvis)
|
// foo(run { x as String; 1 }, { /* x smartcasted to String */ x.length })
|
||||||
* For usual call we have invariant that all arguments will be called before function call, but for
|
//
|
||||||
* when and elvis only one of arguments will be actually called, so it's illegal to pass data flow info
|
// However, as we need to fix type parameters before analyzing lambdas, this is not always the order of analysis;
|
||||||
* from lambda in one of branches
|
// if that is possible, multiple lambdas should be considered to be concurrent.
|
||||||
*/
|
//
|
||||||
private fun dropPostponedLambdasForNonDeterministicCalls() {
|
// foo(run { x as String; genericFunction() }, run { /* x not smartcastable because this lambda may be resolved first */ 1 })
|
||||||
exitsFromCompletedPostponedAnonymousFunctions.clear()
|
// /* x is smartcastable after the call */
|
||||||
|
//
|
||||||
|
// And if the lambda is conditional, then the data flow needs to be merged with other branches.
|
||||||
|
//
|
||||||
|
// foo(nullable?.let { x as String; genericFunction() }, run { 1 })
|
||||||
|
// /* x is not smartcastable */
|
||||||
|
//
|
||||||
|
// foo(nullable ?: run { x as String; genericFunction() }, run { 1 })
|
||||||
|
// /* x is not smartcastable */
|
||||||
|
//
|
||||||
|
// foo(if (condition) run { x as String; genericFunction() } else { genericFunction() }, run { 1 })
|
||||||
|
// /* x is not smartcastable */
|
||||||
|
//
|
||||||
|
// foo(if (condition) run { x as String; genericFunction() } else { x as String; genericFunction() }, run { 1 })
|
||||||
|
// /* x is smartcastable */
|
||||||
|
//
|
||||||
|
// `splitDataFlowForPostponedLambdas` in `enterX` should be matched with either `joinDataFlowFromPostponedLambdasWith`
|
||||||
|
// or `processUnionOfArguments` in `exitX`. The difference is that the latter creates an intersection of all the lambdas'
|
||||||
|
// type information (like after function calls - all casts from all lambdas are valid) while the former is a union
|
||||||
|
// (like after `if` - only the casts from one of the lambdas are valid, and we don't know which).
|
||||||
|
//
|
||||||
|
private fun splitDataFlowForPostponedLambdas() {
|
||||||
|
exitsFromCompletedPostponedAnonymousFunctions.add(mutableListOf())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun joinDataFlowFromPostponedLambdasWith(node: CFGNode<*>): MergePostponedLambdaExitsNode? {
|
||||||
|
val currentLevelExits = exitsFromCompletedPostponedAnonymousFunctions.popLast()
|
||||||
|
if (currentLevelExits.isEmpty()) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
val joinNode = createMergePostponedLambdaExitsNode(node.fir)
|
||||||
|
addEdge(node, joinNode)
|
||||||
|
currentLevelExits.joinDataFlowFromPostponedLambdasTo(joinNode)
|
||||||
|
exitsFromCompletedPostponedAnonymousFunctions.lastOrNull()?.add(joinNode)
|
||||||
|
return joinNode
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun MutableList<CFGNode<*>>.joinDataFlowFromPostponedLambdasTo(node: CFGNode<*>) {
|
||||||
|
for (exitNode in this) {
|
||||||
|
// To avoid storing nodes from subgraphs in the list, we have PostponedLambdaExitNode instead of the real
|
||||||
|
// exit node of the lambda subgraph. The latter is the previous node of the former. Everything else is
|
||||||
|
// already a join/union node in this graph.
|
||||||
|
val functionExitOrMerge = if (exitNode is PostponedLambdaExitNode) exitNode.lastPreviousNode else exitNode
|
||||||
|
addEdge(functionExitOrMerge, node, preferredKind = EdgeKind.DfgForward)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun processUnionOfArguments(
|
private fun processUnionOfArguments(
|
||||||
node: CFGNode<*>,
|
node: CFGNode<*>,
|
||||||
callCompleted: Boolean
|
callCompleted: Boolean
|
||||||
): Pair<EdgeKind, UnionFunctionCallArgumentsNode?> {
|
): Pair<EdgeKind, UnionFunctionCallArgumentsNode?> {
|
||||||
if (!shouldPassFlowFromInplaceLambda.top()) return EdgeKind.Forward to null
|
val currentLevelExits = exitsFromCompletedPostponedAnonymousFunctions.popLast()
|
||||||
var kind = EdgeKind.Forward
|
if (currentLevelExits.isEmpty()) {
|
||||||
if (!callCompleted || exitsFromCompletedPostponedAnonymousFunctions.isEmpty()) {
|
|
||||||
return EdgeKind.Forward to null
|
return EdgeKind.Forward to null
|
||||||
}
|
}
|
||||||
val unionNode by lazy { createUnionFunctionCallArgumentsNode(node.fir) }
|
|
||||||
var hasDirectPreviousNode = false
|
|
||||||
var hasPostponedLambdas = false
|
|
||||||
|
|
||||||
val iterator = exitsFromCompletedPostponedAnonymousFunctions.iterator()
|
if (!callCompleted || !shouldPassFlowFromInplaceLambda.top()) {
|
||||||
val lastPostponedLambdaExitNode = lastNode
|
currentLevelExits.singleOrNull()?.let {
|
||||||
while (iterator.hasNext()) {
|
exitsFromCompletedPostponedAnonymousFunctions.lastOrNull()?.add(it)
|
||||||
val exitNode = iterator.next()
|
return EdgeKind.Forward to null
|
||||||
if (node.level >= exitNode.level) continue
|
|
||||||
hasPostponedLambdas = true
|
|
||||||
if (exitNode == lastPostponedLambdaExitNode) {
|
|
||||||
popAndAddEdge(node, preferredKind = EdgeKind.CfgForward)
|
|
||||||
kind = EdgeKind.DfgForward
|
|
||||||
hasDirectPreviousNode = true
|
|
||||||
}
|
}
|
||||||
addEdge(exitNode.lastPreviousNode, unionNode, preferredKind = EdgeKind.DfgForward)
|
|
||||||
iterator.remove()
|
val unionNode = createUnionFunctionCallArgumentsNode(node.fir)
|
||||||
|
currentLevelExits.joinDataFlowFromPostponedLambdasTo(unionNode)
|
||||||
|
exitsFromCompletedPostponedAnonymousFunctions.lastOrNull()?.addAll(currentLevelExits)
|
||||||
|
return EdgeKind.Forward to unionNode
|
||||||
}
|
}
|
||||||
if (hasPostponedLambdas) {
|
|
||||||
if (hasDirectPreviousNode) {
|
val unionNode = createUnionFunctionCallArgumentsNode(node.fir)
|
||||||
lastNodes.push(unionNode)
|
currentLevelExits.joinDataFlowFromPostponedLambdasTo(unionNode)
|
||||||
} else {
|
|
||||||
addNewSimpleNode(unionNode)
|
if (lastNode in currentLevelExits) {
|
||||||
}
|
popAndAddEdge(node, preferredKind = EdgeKind.CfgForward)
|
||||||
} else {
|
lastNodes.push(unionNode)
|
||||||
return EdgeKind.Forward to null
|
return EdgeKind.DfgForward to unionNode
|
||||||
}
|
}
|
||||||
return Pair(kind, unionNode)
|
addNewSimpleNode(unionNode)
|
||||||
|
return EdgeKind.Forward to unionNode
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exitWhenSubjectExpression(expression: FirWhenSubjectExpression): WhenSubjectExpressionExitNode {
|
fun exitWhenSubjectExpression(expression: FirWhenSubjectExpression): WhenSubjectExpressionExitNode {
|
||||||
@@ -1290,19 +1335,21 @@ class ControlFlowGraphBuilder {
|
|||||||
} else {
|
} else {
|
||||||
addEdge(lastNode, exitNode)
|
addEdge(lastNode, exitNode)
|
||||||
}
|
}
|
||||||
|
splitDataFlowForPostponedLambdas()
|
||||||
return enterNode
|
return enterNode
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exitSafeCall(): ExitSafeCallNode {
|
fun exitSafeCall(): Pair<ExitSafeCallNode, MergePostponedLambdaExitsNode?> {
|
||||||
// There will be two paths towards this exit safe call node:
|
// There will be two paths towards this exit safe call node:
|
||||||
// one from the node prior to the enclosing safe call, and
|
// one from the node prior to the enclosing safe call, and
|
||||||
// the other from the selector part in the enclosing safe call.
|
// the other from the selector part in the enclosing safe call.
|
||||||
// Note that *neither* points to the safe call directly.
|
// Note that *neither* points to the safe call directly.
|
||||||
// So, when it comes to the real exit of the enclosing block/function,
|
// So, when it comes to the real exit of the enclosing block/function,
|
||||||
// the safe call bound to this exit safe call node should be retrieved.
|
// the safe call bound to this exit safe call node should be retrieved.
|
||||||
return exitSafeCallNodes.pop().also {
|
return exitSafeCallNodes.pop().let {
|
||||||
addNewSimpleNode(it)
|
addNewSimpleNode(it)
|
||||||
it.updateDeadStatus()
|
it.updateDeadStatus()
|
||||||
|
it to joinDataFlowFromPostponedLambdasWith(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1310,6 +1357,7 @@ class ControlFlowGraphBuilder {
|
|||||||
|
|
||||||
fun enterElvis(elvisExpression: FirElvisExpression) {
|
fun enterElvis(elvisExpression: FirElvisExpression) {
|
||||||
elvisRhsEnterNodes.push(createElvisRhsEnterNode(elvisExpression))
|
elvisRhsEnterNodes.push(createElvisRhsEnterNode(elvisExpression))
|
||||||
|
splitDataFlowForPostponedLambdas()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exitElvisLhs(elvisExpression: FirElvisExpression): Triple<ElvisLhsExitNode, ElvisLhsIsNotNullNode, ElvisRhsEnterNode> {
|
fun exitElvisLhs(elvisExpression: FirElvisExpression): Triple<ElvisLhsExitNode, ElvisLhsIsNotNullNode, ElvisRhsEnterNode> {
|
||||||
@@ -1342,12 +1390,11 @@ class ControlFlowGraphBuilder {
|
|||||||
return Triple(lhsExitNode, lhsIsNotNullNode, rhsEnterNode)
|
return Triple(lhsExitNode, lhsIsNotNullNode, rhsEnterNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun exitElvis(): ElvisExitNode {
|
fun exitElvis(): Pair<ElvisExitNode, MergePostponedLambdaExitsNode?> {
|
||||||
val exitNode = exitElvisExpressionNodes.pop()
|
val exitNode = exitElvisExpressionNodes.pop()
|
||||||
addNewSimpleNode(exitNode)
|
addNewSimpleNode(exitNode)
|
||||||
exitNode.updateDeadStatus()
|
exitNode.updateDeadStatus()
|
||||||
dropPostponedLambdasForNonDeterministicCalls()
|
return exitNode to joinDataFlowFromPostponedLambdasWith(exitNode)
|
||||||
return exitNode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------- Contract description -----------------------------------
|
// ----------------------------------- Contract description -----------------------------------
|
||||||
|
|||||||
+3
@@ -244,6 +244,9 @@ fun ControlFlowGraphBuilder.createAnonymousObjectExpressionExitNode(fir: FirAnon
|
|||||||
fun ControlFlowGraphBuilder.createUnionFunctionCallArgumentsNode(fir: FirElement): UnionFunctionCallArgumentsNode =
|
fun ControlFlowGraphBuilder.createUnionFunctionCallArgumentsNode(fir: FirElement): UnionFunctionCallArgumentsNode =
|
||||||
UnionFunctionCallArgumentsNode(currentGraph, fir, levelCounter, createId())
|
UnionFunctionCallArgumentsNode(currentGraph, fir, levelCounter, createId())
|
||||||
|
|
||||||
|
fun ControlFlowGraphBuilder.createMergePostponedLambdaExitsNode(fir: FirElement): MergePostponedLambdaExitsNode =
|
||||||
|
MergePostponedLambdaExitsNode(currentGraph, fir, levelCounter, createId())
|
||||||
|
|
||||||
fun ControlFlowGraphBuilder.createClassEnterNode(fir: FirClass): ClassEnterNode =
|
fun ControlFlowGraphBuilder.createClassEnterNode(fir: FirClass): ClassEnterNode =
|
||||||
ClassEnterNode(currentGraph, fir, levelCounter, createId())
|
ClassEnterNode(currentGraph, fir, levelCounter, createId())
|
||||||
|
|
||||||
|
|||||||
+1
@@ -789,6 +789,7 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
|||||||
return checkNotNullCall
|
return checkNotNullCall
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dataFlowAnalyzer.enterCall()
|
||||||
checkNotNullCall.argumentList.transformArguments(transformer, ResolutionMode.ContextDependent)
|
checkNotNullCall.argumentList.transformArguments(transformer, ResolutionMode.ContextDependent)
|
||||||
checkNotNullCall.transformAnnotations(transformer, ResolutionMode.ContextIndependent)
|
checkNotNullCall.transformAnnotations(transformer, ResolutionMode.ContextIndependent)
|
||||||
|
|
||||||
|
|||||||
@@ -228,17 +228,25 @@ class PostponedLambdaEnterNode(owner: ControlFlowGraph, override val fir: FirAno
|
|||||||
return visitor.visitPostponedLambdaEnterNode(this, data)
|
return visitor.visitPostponedLambdaEnterNode(this, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PostponedLambdaExitNode(owner: ControlFlowGraph, override val fir: FirAnonymousFunctionExpression, level: Int, id: Int) : CFGNode<FirAnonymousFunctionExpression>(owner, level, id) {
|
class PostponedLambdaExitNode(owner: ControlFlowGraph, override val fir: FirAnonymousFunctionExpression, level: Int, id: Int) : CFGNode<FirAnonymousFunctionExpression>(owner, level, id) {
|
||||||
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitPostponedLambdaExitNode(this, data)
|
return visitor.visitPostponedLambdaExitNode(this, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class UnionFunctionCallArgumentsNode(owner: ControlFlowGraph, override val fir: FirElement, level: Int, id: Int) : CFGNode<FirElement>(owner, level, id) {
|
class UnionFunctionCallArgumentsNode(owner: ControlFlowGraph, override val fir: FirElement, level: Int, id: Int) : CFGNode<FirElement>(owner, level, id) {
|
||||||
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitUnionFunctionCallArgumentsNode(this, data)
|
return visitor.visitUnionFunctionCallArgumentsNode(this, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MergePostponedLambdaExitsNode(owner: ControlFlowGraph, override val fir: FirElement, level: Int, id: Int) : CFGNode<FirElement>(owner, level, id) {
|
||||||
|
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
|
||||||
|
return visitor.visitMergePostponedLambdaExitsNode(this, data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class AnonymousFunctionExpressionExitNode(owner: ControlFlowGraph, override val fir: FirAnonymousFunctionExpression, level: Int, id: Int) : CFGNode<FirAnonymousFunctionExpression>(owner, level, id) {
|
class AnonymousFunctionExpressionExitNode(owner: ControlFlowGraph, override val fir: FirAnonymousFunctionExpression, level: Int, id: Int) : CFGNode<FirAnonymousFunctionExpression>(owner, level, id) {
|
||||||
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
|
override fun <R, D> accept(visitor: ControlFlowGraphVisitor<R, D>, data: D): R {
|
||||||
return visitor.visitAnonymousFunctionExpressionExitNode(this, data)
|
return visitor.visitAnonymousFunctionExpressionExitNode(this, data)
|
||||||
|
|||||||
@@ -107,6 +107,7 @@ fun CFGNode<*>.render(): String =
|
|||||||
is AnonymousFunctionExpressionExitNode -> "Exit anonymous function expression"
|
is AnonymousFunctionExpressionExitNode -> "Exit anonymous function expression"
|
||||||
|
|
||||||
is UnionFunctionCallArgumentsNode -> "Call arguments union"
|
is UnionFunctionCallArgumentsNode -> "Call arguments union"
|
||||||
|
is MergePostponedLambdaExitsNode -> "Merge postponed lambda exits"
|
||||||
|
|
||||||
is ClassEnterNode -> "Enter class ${owner.name}"
|
is ClassEnterNode -> "Enter class ${owner.name}"
|
||||||
is ClassExitNode -> "Exit class ${owner.name}"
|
is ClassExitNode -> "Exit class ${owner.name}"
|
||||||
|
|||||||
+4
@@ -46,6 +46,10 @@ abstract class ControlFlowGraphVisitor<out R, in D> {
|
|||||||
return visitNode(node, data)
|
return visitNode(node, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun visitMergePostponedLambdaExitsNode(node: MergePostponedLambdaExitsNode, data: D): R {
|
||||||
|
return visitNode(node, data)
|
||||||
|
}
|
||||||
|
|
||||||
open fun visitAnonymousFunctionExpressionExitNode(node: AnonymousFunctionExpressionExitNode, data: D): R {
|
open fun visitAnonymousFunctionExpressionExitNode(node: AnonymousFunctionExpressionExitNode, data: D): R {
|
||||||
return visitNode(node, data)
|
return visitNode(node, data)
|
||||||
}
|
}
|
||||||
|
|||||||
+8
@@ -32,6 +32,10 @@ abstract class ControlFlowGraphVisitorVoid : ControlFlowGraphVisitor<Unit, Nothi
|
|||||||
visitNode(node)
|
visitNode(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open fun visitMergePostponedLambdaExitsNode(node: MergePostponedLambdaExitsNode) {
|
||||||
|
visitNode(node)
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------- Anonymous object -----------------------------------
|
// ----------------------------------- Anonymous object -----------------------------------
|
||||||
|
|
||||||
open fun visitAnonymousObjectExitNode(node: AnonymousObjectExitNode) {
|
open fun visitAnonymousObjectExitNode(node: AnonymousObjectExitNode) {
|
||||||
@@ -325,6 +329,10 @@ abstract class ControlFlowGraphVisitorVoid : ControlFlowGraphVisitor<Unit, Nothi
|
|||||||
visitUnionFunctionCallArgumentsNode(node)
|
visitUnionFunctionCallArgumentsNode(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final override fun visitMergePostponedLambdaExitsNode(node: MergePostponedLambdaExitsNode, data: Nothing?) {
|
||||||
|
visitMergePostponedLambdaExitsNode(node)
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------- Anonymous object -----------------------------------
|
// ----------------------------------- Anonymous object -----------------------------------
|
||||||
|
|
||||||
final override fun visitAnonymousObjectExitNode(node: AnonymousObjectExitNode, data: Nothing?) {
|
final override fun visitAnonymousObjectExitNode(node: AnonymousObjectExitNode, data: Nothing?) {
|
||||||
|
|||||||
+118
-114
@@ -468,7 +468,7 @@ digraph kt44814_kt {
|
|||||||
}
|
}
|
||||||
141 -> {142};
|
141 -> {142};
|
||||||
142 -> {143};
|
142 -> {143};
|
||||||
143 -> {285} [color=green];
|
143 -> {287} [color=green];
|
||||||
|
|
||||||
subgraph cluster_47 {
|
subgraph cluster_47 {
|
||||||
color=red
|
color=red
|
||||||
@@ -595,20 +595,20 @@ digraph kt44814_kt {
|
|||||||
191 [label="Postponed enter to lambda [8]"];
|
191 [label="Postponed enter to lambda [8]"];
|
||||||
subgraph cluster_62 {
|
subgraph cluster_62 {
|
||||||
color=blue
|
color=blue
|
||||||
237 [label="Enter function anonymousFunction [9]" style="filled" fillcolor=red];
|
239 [label="Enter function anonymousFunction [9]" style="filled" fillcolor=red];
|
||||||
subgraph cluster_63 {
|
subgraph cluster_63 {
|
||||||
color=blue
|
color=blue
|
||||||
238 [label="Enter block [9]"];
|
240 [label="Enter block [9]"];
|
||||||
239 [label="Access variable R|<local>/it| [9]"];
|
241 [label="Access variable R|<local>/it| [9]"];
|
||||||
240 [label="Enter safe call [9]"];
|
242 [label="Enter safe call [9]"];
|
||||||
241 [label="Access variable R|/LighterASTNode.tokenType| [9]"];
|
243 [label="Access variable R|/LighterASTNode.tokenType| [9]"];
|
||||||
242 [label="Exit safe call [9]"];
|
244 [label="Exit safe call [9]"];
|
||||||
243 [label="Access qualifier /TokenType [9]"];
|
245 [label="Access qualifier /TokenType [9]"];
|
||||||
244 [label="Access variable R|/TokenType.Companion.MODIFIER_LIST| [9]"];
|
246 [label="Access variable R|/TokenType.Companion.MODIFIER_LIST| [9]"];
|
||||||
245 [label="Equality operator == [9]"];
|
247 [label="Equality operator == [9]"];
|
||||||
246 [label="Exit block [9]"];
|
248 [label="Exit block [9]"];
|
||||||
}
|
}
|
||||||
247 [label="Exit function anonymousFunction [9]" style="filled" fillcolor=red];
|
249 [label="Exit function anonymousFunction [9]" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
192 [label="Postponed exit from lambda [8]"];
|
192 [label="Postponed exit from lambda [8]"];
|
||||||
193 [label="Function call: this@R|/FirModifierList.Companion.getModifierList|.R|/FirLightSourceElement.lighterASTNode|.R|/LighterASTNode.getChildren|(...).R|kotlin/collections/find|<R|LighterASTNode?|>(...) [7]"];
|
193 [label="Function call: this@R|/FirModifierList.Companion.getModifierList|.R|/FirLightSourceElement.lighterASTNode|.R|/LighterASTNode.getChildren|(...).R|kotlin/collections/find|<R|LighterASTNode?|>(...) [7]"];
|
||||||
@@ -639,15 +639,15 @@ digraph kt44814_kt {
|
|||||||
215 [label="Postponed enter to lambda [7]"];
|
215 [label="Postponed enter to lambda [7]"];
|
||||||
subgraph cluster_65 {
|
subgraph cluster_65 {
|
||||||
color=blue
|
color=blue
|
||||||
231 [label="Enter function anonymousFunction [8]" style="filled" fillcolor=red];
|
233 [label="Enter function anonymousFunction [8]" style="filled" fillcolor=red];
|
||||||
subgraph cluster_66 {
|
subgraph cluster_66 {
|
||||||
color=blue
|
color=blue
|
||||||
232 [label="Enter block [8]"];
|
234 [label="Enter block [8]"];
|
||||||
233 [label="Access variable R|<local>/it| [9]"];
|
235 [label="Access variable R|<local>/it| [9]"];
|
||||||
234 [label="Function call: R|/FirModifierList.FirPsiModifierList.FirPsiModifierList|(...) [8]"];
|
236 [label="Function call: R|/FirModifierList.FirPsiModifierList.FirPsiModifierList|(...) [8]"];
|
||||||
235 [label="Exit block [8]"];
|
237 [label="Exit block [8]"];
|
||||||
}
|
}
|
||||||
236 [label="Exit function anonymousFunction [8]" style="filled" fillcolor=red];
|
238 [label="Exit function anonymousFunction [8]" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
216 [label="Postponed exit from lambda [7]"];
|
216 [label="Postponed exit from lambda [7]"];
|
||||||
217 [label="Function call: $subj$.R|kotlin/let|<R|KtModifierList|, R|FirModifierList.FirPsiModifierList|>(...) [6]"];
|
217 [label="Function call: $subj$.R|kotlin/let|<R|KtModifierList|, R|FirModifierList.FirPsiModifierList|>(...) [6]"];
|
||||||
@@ -655,17 +655,18 @@ digraph kt44814_kt {
|
|||||||
219 [label="Exit block [6]"];
|
219 [label="Exit block [6]"];
|
||||||
}
|
}
|
||||||
220 [label="Exit when branch result [5]"];
|
220 [label="Exit when branch result [5]"];
|
||||||
221 [label="Enter when branch result [5]"];
|
221 [label="Merge postponed lambda exits [6]"];
|
||||||
|
222 [label="Enter when branch result [5]"];
|
||||||
subgraph cluster_67 {
|
subgraph cluster_67 {
|
||||||
color=blue
|
color=blue
|
||||||
222 [label="Enter block [5]"];
|
223 [label="Enter block [5]"];
|
||||||
223 [label="Const: Null(null) [5]"];
|
224 [label="Const: Null(null) [5]"];
|
||||||
224 [label="Exit block [5]"];
|
225 [label="Exit block [5]"];
|
||||||
}
|
}
|
||||||
225 [label="Exit when branch result [4]"];
|
226 [label="Exit when branch result [4]"];
|
||||||
226 [label="Exit when [3]"];
|
227 [label="Exit when [3]"];
|
||||||
}
|
}
|
||||||
227 [label="Jump: ^getModifierList when (this@R|/FirModifierList.Companion.getModifierList|) {
|
228 [label="Jump: ^getModifierList when (this@R|/FirModifierList.Companion.getModifierList|) {
|
||||||
==($subj$, Null(null)) -> {
|
==($subj$, Null(null)) -> {
|
||||||
Null(null)
|
Null(null)
|
||||||
}
|
}
|
||||||
@@ -684,11 +685,12 @@ digraph kt44814_kt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[3]"];
|
[3]"];
|
||||||
228 [label="Stub [3]" style="filled" fillcolor=gray];
|
229 [label="Stub [3]" style="filled" fillcolor=gray];
|
||||||
229 [label="Exit block [3]" style="filled" fillcolor=gray];
|
230 [label="Exit block [3]" style="filled" fillcolor=gray];
|
||||||
}
|
}
|
||||||
230 [label="Exit function getModifierList [3]" style="filled" fillcolor=red];
|
231 [label="Exit function getModifierList [3]" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
|
232 [label="Merge postponed lambda exits [3]"];
|
||||||
169 -> {170};
|
169 -> {170};
|
||||||
170 -> {171};
|
170 -> {171};
|
||||||
171 -> {172};
|
171 -> {172};
|
||||||
@@ -697,7 +699,7 @@ digraph kt44814_kt {
|
|||||||
174 -> {175};
|
174 -> {175};
|
||||||
175 -> {176};
|
175 -> {176};
|
||||||
176 -> {177};
|
176 -> {177};
|
||||||
177 -> {221 178};
|
177 -> {222 178};
|
||||||
178 -> {179};
|
178 -> {179};
|
||||||
179 -> {180};
|
179 -> {180};
|
||||||
180 -> {181};
|
180 -> {181};
|
||||||
@@ -711,15 +713,15 @@ digraph kt44814_kt {
|
|||||||
188 -> {189};
|
188 -> {189};
|
||||||
189 -> {190};
|
189 -> {190};
|
||||||
190 -> {191};
|
190 -> {191};
|
||||||
191 -> {237};
|
191 -> {239};
|
||||||
191 -> {192} [color=red];
|
191 -> {192} [color=red];
|
||||||
191 -> {237} [style=dashed];
|
191 -> {239} [style=dashed];
|
||||||
192 -> {193};
|
192 -> {193};
|
||||||
193 -> {194};
|
193 -> {194};
|
||||||
194 -> {199 195};
|
194 -> {199 195};
|
||||||
195 -> {196};
|
195 -> {196};
|
||||||
196 -> {197};
|
196 -> {197};
|
||||||
197 -> {230};
|
197 -> {231};
|
||||||
197 -> {198} [style=dotted];
|
197 -> {198} [style=dotted];
|
||||||
198 -> {200} [style=dotted];
|
198 -> {200} [style=dotted];
|
||||||
199 -> {200};
|
199 -> {200};
|
||||||
@@ -729,7 +731,7 @@ digraph kt44814_kt {
|
|||||||
203 -> {204};
|
203 -> {204};
|
||||||
204 -> {205};
|
204 -> {205};
|
||||||
205 -> {206};
|
205 -> {206};
|
||||||
206 -> {226};
|
206 -> {227};
|
||||||
207 -> {208};
|
207 -> {208};
|
||||||
208 -> {209};
|
208 -> {209};
|
||||||
209 -> {210};
|
209 -> {210};
|
||||||
@@ -738,92 +740,94 @@ digraph kt44814_kt {
|
|||||||
212 -> {213};
|
212 -> {213};
|
||||||
213 -> {214 218};
|
213 -> {214 218};
|
||||||
214 -> {215};
|
214 -> {215};
|
||||||
215 -> {231};
|
215 -> {233};
|
||||||
215 -> {216} [color=red];
|
215 -> {216} [color=red];
|
||||||
215 -> {231} [style=dashed];
|
215 -> {233} [style=dashed];
|
||||||
216 -> {217};
|
216 -> {217};
|
||||||
217 -> {218};
|
217 -> {218};
|
||||||
218 -> {219};
|
218 -> {221 219};
|
||||||
219 -> {220};
|
219 -> {220};
|
||||||
220 -> {226};
|
220 -> {227};
|
||||||
221 -> {222};
|
221 -> {232} [color=red];
|
||||||
222 -> {223};
|
222 -> {223};
|
||||||
223 -> {224};
|
223 -> {224};
|
||||||
224 -> {225};
|
224 -> {225};
|
||||||
225 -> {226};
|
225 -> {226};
|
||||||
226 -> {227};
|
226 -> {227};
|
||||||
227 -> {230};
|
227 -> {232 228};
|
||||||
227 -> {228} [style=dotted];
|
228 -> {231};
|
||||||
228 -> {229} [style=dotted];
|
228 -> {229} [style=dotted];
|
||||||
229 -> {230} [style=dotted];
|
229 -> {230} [style=dotted];
|
||||||
231 -> {232};
|
230 -> {231} [style=dotted];
|
||||||
232 -> {233};
|
|
||||||
233 -> {234};
|
233 -> {234};
|
||||||
234 -> {235};
|
234 -> {235};
|
||||||
235 -> {236};
|
235 -> {236};
|
||||||
236 -> {216} [color=green];
|
236 -> {237};
|
||||||
237 -> {247 238};
|
237 -> {238};
|
||||||
238 -> {239};
|
238 -> {221} [color=red];
|
||||||
239 -> {240 242};
|
238 -> {216} [color=green];
|
||||||
|
239 -> {249 240};
|
||||||
240 -> {241};
|
240 -> {241};
|
||||||
241 -> {242};
|
241 -> {242 244};
|
||||||
242 -> {243};
|
242 -> {243};
|
||||||
243 -> {244};
|
243 -> {244};
|
||||||
244 -> {245};
|
244 -> {245};
|
||||||
245 -> {246};
|
245 -> {246};
|
||||||
246 -> {247};
|
246 -> {247};
|
||||||
247 -> {192} [color=green];
|
247 -> {248};
|
||||||
247 -> {237} [color=green style=dashed];
|
248 -> {249};
|
||||||
|
249 -> {192} [color=green];
|
||||||
|
249 -> {239} [color=green style=dashed];
|
||||||
|
|
||||||
subgraph cluster_68 {
|
subgraph cluster_68 {
|
||||||
color=red
|
color=red
|
||||||
248 [label="Enter function boxImpl [3]" style="filled" fillcolor=red];
|
250 [label="Enter function boxImpl [3]" style="filled" fillcolor=red];
|
||||||
subgraph cluster_69 {
|
subgraph cluster_69 {
|
||||||
color=blue
|
color=blue
|
||||||
249 [label="Enter block [3]"];
|
251 [label="Enter block [3]"];
|
||||||
250 [label="Function call: R|/LighterASTNode.LighterASTNode|() [6]"];
|
252 [label="Function call: R|/LighterASTNode.LighterASTNode|() [6]"];
|
||||||
251 [label="Function call: R|kotlin/collections/listOf|<R|LighterASTNode|>(...) [5]"];
|
253 [label="Function call: R|kotlin/collections/listOf|<R|LighterASTNode|>(...) [5]"];
|
||||||
252 [label="Function call: R|/LighterASTNode.LighterASTNode|(...) [4]"];
|
254 [label="Function call: R|/LighterASTNode.LighterASTNode|(...) [4]"];
|
||||||
253 [label="Function call: R|/FlyweightCapableTreeStructure.FlyweightCapableTreeStructure|() [4]"];
|
255 [label="Function call: R|/FlyweightCapableTreeStructure.FlyweightCapableTreeStructure|() [4]"];
|
||||||
254 [label="Function call: R|/FirLightSourceElement.FirLightSourceElement|(...) [3]"];
|
256 [label="Function call: R|/FirLightSourceElement.FirLightSourceElement|(...) [3]"];
|
||||||
255 [label="Variable declaration: lval sourceElement: R|FirSourceElement?| [3]"];
|
257 [label="Variable declaration: lval sourceElement: R|FirSourceElement?| [3]"];
|
||||||
256 [label="Access variable R|<local>/sourceElement| [4]"];
|
258 [label="Access variable R|<local>/sourceElement| [4]"];
|
||||||
257 [label="Function call: (this@R|/FirModifierList.Companion|, R|<local>/sourceElement|).R|/FirModifierList.Companion.getModifierList|() [3]"];
|
259 [label="Function call: (this@R|/FirModifierList.Companion|, R|<local>/sourceElement|).R|/FirModifierList.Companion.getModifierList|() [3]"];
|
||||||
258 [label="Variable declaration: lval result: R|FirModifierList?| [3]"];
|
260 [label="Variable declaration: lval result: R|FirModifierList?| [3]"];
|
||||||
subgraph cluster_70 {
|
subgraph cluster_70 {
|
||||||
color=blue
|
color=blue
|
||||||
259 [label="Enter when [3]"];
|
261 [label="Enter when [3]"];
|
||||||
subgraph cluster_71 {
|
subgraph cluster_71 {
|
||||||
color=blue
|
color=blue
|
||||||
260 [label="Enter when branch condition [4]"];
|
262 [label="Enter when branch condition [4]"];
|
||||||
261 [label="Access variable R|<local>/result| [5]"];
|
263 [label="Access variable R|<local>/result| [5]"];
|
||||||
262 [label="Type operator: (R|<local>/result| is R|FirModifierList.FirLightModifierList|) [5]"];
|
264 [label="Type operator: (R|<local>/result| is R|FirModifierList.FirLightModifierList|) [5]"];
|
||||||
263 [label="Exit when branch condition [4]"];
|
265 [label="Exit when branch condition [4]"];
|
||||||
}
|
}
|
||||||
subgraph cluster_72 {
|
subgraph cluster_72 {
|
||||||
color=blue
|
color=blue
|
||||||
264 [label="Enter when branch condition else [5]"];
|
266 [label="Enter when branch condition else [5]"];
|
||||||
265 [label="Exit when branch condition [5]"];
|
267 [label="Exit when branch condition [5]"];
|
||||||
}
|
}
|
||||||
266 [label="Enter when branch result [6]"];
|
268 [label="Enter when branch result [6]"];
|
||||||
subgraph cluster_73 {
|
subgraph cluster_73 {
|
||||||
color=blue
|
color=blue
|
||||||
267 [label="Enter block [6]"];
|
269 [label="Enter block [6]"];
|
||||||
268 [label="Const: String(Fail) [6]"];
|
270 [label="Const: String(Fail) [6]"];
|
||||||
269 [label="Exit block [6]"];
|
271 [label="Exit block [6]"];
|
||||||
}
|
}
|
||||||
270 [label="Exit when branch result [5]"];
|
272 [label="Exit when branch result [5]"];
|
||||||
271 [label="Enter when branch result [5]"];
|
273 [label="Enter when branch result [5]"];
|
||||||
subgraph cluster_74 {
|
subgraph cluster_74 {
|
||||||
color=blue
|
color=blue
|
||||||
272 [label="Enter block [5]"];
|
274 [label="Enter block [5]"];
|
||||||
273 [label="Const: String(OK) [5]"];
|
275 [label="Const: String(OK) [5]"];
|
||||||
274 [label="Exit block [5]"];
|
276 [label="Exit block [5]"];
|
||||||
}
|
}
|
||||||
275 [label="Exit when branch result [4]"];
|
277 [label="Exit when branch result [4]"];
|
||||||
276 [label="Exit when [3]"];
|
278 [label="Exit when [3]"];
|
||||||
}
|
}
|
||||||
277 [label="Jump: ^boxImpl when () {
|
279 [label="Jump: ^boxImpl when () {
|
||||||
(R|<local>/result| is R|FirModifierList.FirLightModifierList|) -> {
|
(R|<local>/result| is R|FirModifierList.FirLightModifierList|) -> {
|
||||||
String(OK)
|
String(OK)
|
||||||
}
|
}
|
||||||
@@ -832,13 +836,11 @@ digraph kt44814_kt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[3]"];
|
[3]"];
|
||||||
278 [label="Stub [3]" style="filled" fillcolor=gray];
|
280 [label="Stub [3]" style="filled" fillcolor=gray];
|
||||||
279 [label="Exit block [3]" style="filled" fillcolor=gray];
|
281 [label="Exit block [3]" style="filled" fillcolor=gray];
|
||||||
}
|
}
|
||||||
280 [label="Exit function boxImpl [3]" style="filled" fillcolor=red];
|
282 [label="Exit function boxImpl [3]" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
248 -> {249};
|
|
||||||
249 -> {250};
|
|
||||||
250 -> {251};
|
250 -> {251};
|
||||||
251 -> {252};
|
251 -> {252};
|
||||||
252 -> {253};
|
252 -> {253};
|
||||||
@@ -852,64 +854,66 @@ digraph kt44814_kt {
|
|||||||
260 -> {261};
|
260 -> {261};
|
||||||
261 -> {262};
|
261 -> {262};
|
||||||
262 -> {263};
|
262 -> {263};
|
||||||
263 -> {271 264};
|
263 -> {264};
|
||||||
264 -> {265};
|
264 -> {265};
|
||||||
265 -> {266};
|
265 -> {273 266};
|
||||||
266 -> {267};
|
266 -> {267};
|
||||||
267 -> {268};
|
267 -> {268};
|
||||||
268 -> {269};
|
268 -> {269};
|
||||||
269 -> {270};
|
269 -> {270};
|
||||||
270 -> {276};
|
270 -> {271};
|
||||||
271 -> {272};
|
271 -> {272};
|
||||||
272 -> {273};
|
272 -> {278};
|
||||||
273 -> {274};
|
273 -> {274};
|
||||||
274 -> {275};
|
274 -> {275};
|
||||||
275 -> {276};
|
275 -> {276};
|
||||||
276 -> {277};
|
276 -> {277};
|
||||||
277 -> {280};
|
277 -> {278};
|
||||||
277 -> {278} [style=dotted];
|
278 -> {279};
|
||||||
278 -> {279} [style=dotted];
|
279 -> {282};
|
||||||
279 -> {280} [style=dotted];
|
279 -> {280} [style=dotted];
|
||||||
|
280 -> {281} [style=dotted];
|
||||||
|
281 -> {282} [style=dotted];
|
||||||
|
|
||||||
subgraph cluster_75 {
|
subgraph cluster_75 {
|
||||||
color=red
|
color=red
|
||||||
281 [label="Enter class Companion [2]" style="filled" fillcolor=red];
|
283 [label="Enter class Companion [2]" style="filled" fillcolor=red];
|
||||||
282 [label="Exit class Companion [2]" style="filled" fillcolor=red];
|
284 [label="Exit class Companion [2]" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
281 -> {282} [color=green];
|
283 -> {284} [color=green];
|
||||||
|
|
||||||
subgraph cluster_76 {
|
subgraph cluster_76 {
|
||||||
color=red
|
color=red
|
||||||
283 [label="Enter class FirModifierList [1]" style="filled" fillcolor=red];
|
285 [label="Enter class FirModifierList [1]" style="filled" fillcolor=red];
|
||||||
284 [label="Part of class initialization [1]"];
|
286 [label="Part of class initialization [1]"];
|
||||||
285 [label="Exit class FirModifierList [1]" style="filled" fillcolor=red];
|
287 [label="Exit class FirModifierList [1]" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
283 -> {284} [color=green];
|
285 -> {286} [color=green];
|
||||||
284 -> {285} [style=dotted];
|
286 -> {287} [style=dotted];
|
||||||
284 -> {141} [color=green];
|
286 -> {141} [color=green];
|
||||||
284 -> {141} [style=dashed];
|
286 -> {141} [style=dashed];
|
||||||
|
|
||||||
subgraph cluster_77 {
|
subgraph cluster_77 {
|
||||||
color=red
|
color=red
|
||||||
286 [label="Enter function box [1]" style="filled" fillcolor=red];
|
288 [label="Enter function box [1]" style="filled" fillcolor=red];
|
||||||
subgraph cluster_78 {
|
subgraph cluster_78 {
|
||||||
color=blue
|
color=blue
|
||||||
287 [label="Enter block [1]"];
|
289 [label="Enter block [1]"];
|
||||||
288 [label="Access qualifier /FirModifierList [2]"];
|
290 [label="Access qualifier /FirModifierList [2]"];
|
||||||
289 [label="Function call: Q|FirModifierList|.R|/FirModifierList.Companion.boxImpl|() [1]"];
|
291 [label="Function call: Q|FirModifierList|.R|/FirModifierList.Companion.boxImpl|() [1]"];
|
||||||
290 [label="Jump: ^box Q|FirModifierList|.R|/FirModifierList.Companion.boxImpl|() [1]"];
|
292 [label="Jump: ^box Q|FirModifierList|.R|/FirModifierList.Companion.boxImpl|() [1]"];
|
||||||
291 [label="Stub [1]" style="filled" fillcolor=gray];
|
293 [label="Stub [1]" style="filled" fillcolor=gray];
|
||||||
292 [label="Exit block [1]" style="filled" fillcolor=gray];
|
294 [label="Exit block [1]" style="filled" fillcolor=gray];
|
||||||
}
|
}
|
||||||
293 [label="Exit function box [1]" style="filled" fillcolor=red];
|
295 [label="Exit function box [1]" style="filled" fillcolor=red];
|
||||||
}
|
}
|
||||||
286 -> {287};
|
|
||||||
287 -> {288};
|
|
||||||
288 -> {289};
|
288 -> {289};
|
||||||
289 -> {290};
|
289 -> {290};
|
||||||
290 -> {293};
|
290 -> {291};
|
||||||
290 -> {291} [style=dotted];
|
291 -> {292};
|
||||||
291 -> {292} [style=dotted];
|
292 -> {295};
|
||||||
292 -> {293} [style=dotted];
|
292 -> {293} [style=dotted];
|
||||||
|
293 -> {294} [style=dotted];
|
||||||
|
294 -> {295} [style=dotted];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -6,6 +6,6 @@ fun foo(y: String?) {
|
|||||||
var x: String? = ""
|
var x: String? = ""
|
||||||
if (x != null) {
|
if (x != null) {
|
||||||
bar(y?.let { x = null; it })<!UNSAFE_CALL!>.<!>length
|
bar(y?.let { x = null; it })<!UNSAFE_CALL!>.<!>length
|
||||||
x.length // Smart cast is not possible
|
x<!UNSAFE_CALL!>.<!>length // Smart cast is not possible
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -3,8 +3,8 @@ fun foo(y: String?) {
|
|||||||
if (x != null) {
|
if (x != null) {
|
||||||
with(y?.let { x = null; it }) {
|
with(y?.let { x = null; it }) {
|
||||||
this<!UNSAFE_CALL!>.<!>length
|
this<!UNSAFE_CALL!>.<!>length
|
||||||
x.length
|
x<!UNSAFE_CALL!>.<!>length
|
||||||
}
|
}
|
||||||
x.length
|
x<!UNSAFE_CALL!>.<!>length
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user