[FIR-TEST] Move analysis tests to separate module

This commit is contained in:
Dmitriy Novozhilov
2020-03-18 15:10:46 +03:00
parent 3a479d5d16
commit cc07ae96b3
1477 changed files with 1001 additions and 980 deletions
@@ -0,0 +1,285 @@
digraph elvis_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function foo" style="filled" fillcolor=red];
1 [label="Exit function foo" style="filled" fillcolor=red];
}
0 -> {1};
subgraph cluster_1 {
color=red
2 [label="Enter function getter" style="filled" fillcolor=red];
3 [label="Exit function getter" style="filled" fillcolor=red];
}
2 -> {3};
subgraph cluster_2 {
color=red
4 [label="Enter property" style="filled" fillcolor=red];
5 [label="Exit property" style="filled" fillcolor=red];
}
4 -> {5};
subgraph cluster_3 {
color=red
6 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_4 {
color=blue
7 [label="Enter when"];
subgraph cluster_5 {
color=blue
8 [label="Enter when branch condition "];
subgraph cluster_6 {
color=blue
9 [label="Enter when"];
10 [label="Access variable R|<local>/x|"];
11 [label="Enter safe call"];
12 [label="Access variable R|/A.b|"];
13 [label="Exit safe call"];
14 [label="Variable declaration: lval <elvis>: R|kotlin/Boolean?|"];
subgraph cluster_7 {
color=blue
15 [label="Enter when branch condition "];
16 [label="Const: Null(null)"];
17 [label="Operator =="];
18 [label="Exit when branch condition"];
}
subgraph cluster_8 {
color=blue
19 [label="Enter when branch condition else"];
20 [label="Exit when branch condition"];
}
21 [label="Enter when branch result"];
subgraph cluster_9 {
color=blue
22 [label="Enter block"];
23 [label="Access variable R|<local>/<elvis>|"];
24 [label="Exit block"];
}
25 [label="Exit when branch result"];
26 [label="Enter when branch result"];
subgraph cluster_10 {
color=blue
27 [label="Enter block"];
28 [label="Jump: ^test_1 Unit"];
29 [label="Stub" style="filled" fillcolor=gray];
30 [label="Exit block" style="filled" fillcolor=gray];
}
31 [label="Exit when branch result" style="filled" fillcolor=gray];
32 [label="Exit when"];
}
33 [label="Exit when branch condition"];
}
34 [label="Synthetic else branch"];
35 [label="Enter when branch result"];
subgraph cluster_11 {
color=blue
36 [label="Enter block"];
37 [label="Access variable R|<local>/x|"];
38 [label="Function call: R|<local>/x|.R|/A.foo|()"];
39 [label="Exit block"];
}
40 [label="Exit when branch result"];
41 [label="Exit when"];
}
42 [label="Exit function test_1" style="filled" fillcolor=red];
}
6 -> {7};
7 -> {8};
8 -> {9};
9 -> {10};
10 -> {11 13};
11 -> {12};
12 -> {13};
13 -> {14};
14 -> {15};
15 -> {16};
16 -> {17};
17 -> {18};
18 -> {26 19};
19 -> {20};
20 -> {21};
21 -> {22};
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {32};
26 -> {27};
27 -> {28};
28 -> {42};
28 -> {29} [style=dotted];
29 -> {30} [style=dotted];
30 -> {31} [style=dotted];
31 -> {32} [style=dotted];
32 -> {33};
33 -> {35 34};
34 -> {41};
35 -> {36};
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {42};
subgraph cluster_12 {
color=red
43 [label="Enter function test2" style="filled" fillcolor=red];
subgraph cluster_13 {
color=blue
44 [label="Enter when"];
subgraph cluster_14 {
color=blue
45 [label="Enter when branch condition "];
46 [label="Access variable R|<local>/b|"];
47 [label="Type operator: (R|<local>/b| !is R|kotlin/String|)"];
48 [label="Exit when branch condition"];
}
49 [label="Synthetic else branch"];
50 [label="Enter when branch result"];
subgraph cluster_15 {
color=blue
51 [label="Enter block"];
52 [label="Const: String()"];
53 [label="Jump: ^test2 String()"];
54 [label="Stub" style="filled" fillcolor=gray];
55 [label="Exit block" style="filled" fillcolor=gray];
}
56 [label="Exit when branch result" style="filled" fillcolor=gray];
57 [label="Exit when"];
}
subgraph cluster_16 {
color=blue
58 [label="Enter when"];
subgraph cluster_17 {
color=blue
59 [label="Enter when branch condition "];
60 [label="Access variable R|<local>/a|"];
61 [label="Type operator: (R|<local>/a| !is R|kotlin/String?|)"];
62 [label="Exit when branch condition"];
}
63 [label="Synthetic else branch"];
64 [label="Enter when branch result"];
subgraph cluster_18 {
color=blue
65 [label="Enter block"];
66 [label="Const: String()"];
67 [label="Jump: ^test2 String()"];
68 [label="Stub" style="filled" fillcolor=gray];
69 [label="Exit block" style="filled" fillcolor=gray];
}
70 [label="Exit when branch result" style="filled" fillcolor=gray];
71 [label="Exit when"];
}
subgraph cluster_19 {
color=blue
72 [label="Enter when"];
73 [label="Access variable R|<local>/a|"];
74 [label="Variable declaration: lval <elvis>: R|kotlin/String?|"];
subgraph cluster_20 {
color=blue
75 [label="Enter when branch condition "];
76 [label="Const: Null(null)"];
77 [label="Operator =="];
78 [label="Exit when branch condition"];
}
subgraph cluster_21 {
color=blue
79 [label="Enter when branch condition else"];
80 [label="Exit when branch condition"];
}
81 [label="Enter when branch result"];
subgraph cluster_22 {
color=blue
82 [label="Enter block"];
83 [label="Access variable R|<local>/<elvis>|"];
84 [label="Exit block"];
}
85 [label="Exit when branch result"];
86 [label="Enter when branch result"];
subgraph cluster_23 {
color=blue
87 [label="Enter block"];
88 [label="Access variable R|<local>/b|"];
89 [label="Exit block"];
}
90 [label="Exit when branch result"];
91 [label="Exit when"];
}
92 [label="Jump: ^test2 when (lval <elvis>: R|kotlin/String?| = R|<local>/a|) {
==($subj$, Null(null)) -> {
R|<local>/b|
}
else -> {
R|<local>/<elvis>|
}
}
"];
93 [label="Stub" style="filled" fillcolor=gray];
94 [label="Exit function test2" style="filled" fillcolor=red];
}
43 -> {44};
44 -> {45};
45 -> {46};
46 -> {47};
47 -> {48};
48 -> {50 49};
49 -> {57};
50 -> {51};
51 -> {52};
52 -> {53};
53 -> {94};
53 -> {54} [style=dotted];
54 -> {55} [style=dotted];
55 -> {56} [style=dotted];
56 -> {57} [style=dotted];
57 -> {58};
58 -> {59};
59 -> {60};
60 -> {61};
61 -> {62};
62 -> {64 63};
63 -> {71};
64 -> {65};
65 -> {66};
66 -> {67};
67 -> {94};
67 -> {68} [style=dotted];
68 -> {69} [style=dotted];
69 -> {70} [style=dotted];
70 -> {71} [style=dotted];
71 -> {72};
72 -> {73};
73 -> {74};
74 -> {75};
75 -> {76};
76 -> {77};
77 -> {78};
78 -> {86 79};
79 -> {80};
80 -> {81};
81 -> {82};
82 -> {83};
83 -> {84};
84 -> {85};
85 -> {91};
86 -> {87};
87 -> {88};
88 -> {89};
89 -> {90};
90 -> {91};
91 -> {92};
92 -> {94};
92 -> {93} [style=dotted];
93 -> {94} [style=dotted];
}
@@ -0,0 +1,17 @@
// !DUMP_CFG
interface A {
fun foo()
val b: Boolean
}
fun test_1(x: A?) {
if (x?.b ?: return) {
x.foo()
}
}
fun test2(a: Any?, b: Any?): String {
if (b !is String) return ""
if (a !is String?) return ""
return a ?: b
}
@@ -0,0 +1,47 @@
FILE: elvis.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Unit|
public abstract val b: R|kotlin/Boolean|
public get(): R|kotlin/Boolean|
}
public final fun test_1(x: R|A?|): R|kotlin/Unit| {
when () {
when (lval <elvis>: R|kotlin/Boolean?| = R|<local>/x|?.R|/A.b|) {
==($subj$, Null(null)) -> {
^test_1 Unit
}
else -> {
R|<local>/<elvis>|
}
}
-> {
R|<local>/x|.R|/A.foo|()
}
}
}
public final fun test2(a: R|kotlin/Any?|, b: R|kotlin/Any?|): R|kotlin/String| {
when () {
(R|<local>/b| !is R|kotlin/String|) -> {
^test2 String()
}
}
when () {
(R|<local>/a| !is R|kotlin/String?|) -> {
^test2 String()
}
}
^test2 when (lval <elvis>: R|kotlin/String?| = R|<local>/a|) {
==($subj$, Null(null)) -> {
R|<local>/b|
}
else -> {
R|<local>/<elvis>|
}
}
}
@@ -0,0 +1,480 @@
digraph returns_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function test_0" style="filled" fillcolor=red];
subgraph cluster_1 {
color=blue
1 [label="Enter when"];
subgraph cluster_2 {
color=blue
2 [label="Enter when branch condition "];
3 [label="Access variable R|<local>/x|"];
4 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
5 [label="Exit when branch condition"];
}
subgraph cluster_3 {
color=blue
6 [label="Enter when branch condition else"];
7 [label="Exit when branch condition"];
}
8 [label="Enter when branch result"];
subgraph cluster_4 {
color=blue
9 [label="Enter block"];
10 [label="Exit block"];
}
11 [label="Exit when branch result"];
12 [label="Enter when branch result"];
subgraph cluster_5 {
color=blue
13 [label="Enter block"];
14 [label="Access variable R|<local>/x|"];
15 [label="Access variable R|kotlin/String.length|"];
16 [label="Exit block"];
}
17 [label="Exit when branch result"];
18 [label="Exit when"];
}
19 [label="Access variable R|<local>/x|"];
20 [label="Access variable <Unresolved name: length>#"];
21 [label="Exit function test_0" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
2 -> {3};
3 -> {4};
4 -> {5};
5 -> {12 6};
6 -> {7};
7 -> {8};
8 -> {9};
9 -> {10};
10 -> {11};
11 -> {18};
12 -> {13};
13 -> {14};
14 -> {15};
15 -> {16};
16 -> {17};
17 -> {18};
18 -> {19};
19 -> {20};
20 -> {21};
subgraph cluster_6 {
color=red
22 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_7 {
color=blue
23 [label="Enter when"];
subgraph cluster_8 {
color=blue
24 [label="Enter when branch condition "];
25 [label="Access variable R|<local>/x|"];
26 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
27 [label="Exit when branch condition"];
}
subgraph cluster_9 {
color=blue
28 [label="Enter when branch condition else"];
29 [label="Exit when branch condition"];
}
30 [label="Enter when branch result"];
subgraph cluster_10 {
color=blue
31 [label="Enter block"];
32 [label="Jump: ^test_1 Unit"];
33 [label="Stub" style="filled" fillcolor=gray];
34 [label="Exit block" style="filled" fillcolor=gray];
}
35 [label="Exit when branch result" style="filled" fillcolor=gray];
36 [label="Enter when branch result"];
subgraph cluster_11 {
color=blue
37 [label="Enter block"];
38 [label="Access variable R|<local>/x|"];
39 [label="Access variable R|kotlin/String.length|"];
40 [label="Exit block"];
}
41 [label="Exit when branch result"];
42 [label="Exit when"];
}
43 [label="Access variable R|<local>/x|"];
44 [label="Access variable R|kotlin/String.length|"];
45 [label="Exit function test_1" style="filled" fillcolor=red];
}
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {26};
26 -> {27};
27 -> {36 28};
28 -> {29};
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {45};
32 -> {33} [style=dotted];
33 -> {34} [style=dotted];
34 -> {35} [style=dotted];
35 -> {42} [style=dotted];
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {45};
subgraph cluster_12 {
color=red
46 [label="Enter function foo" style="filled" fillcolor=red];
47 [label="Exit function foo" style="filled" fillcolor=red];
}
46 -> {47};
subgraph cluster_13 {
color=red
48 [label="Enter function bar" style="filled" fillcolor=red];
49 [label="Exit function bar" style="filled" fillcolor=red];
}
48 -> {49};
subgraph cluster_14 {
color=red
50 [label="Enter function baz" style="filled" fillcolor=red];
51 [label="Exit function baz" style="filled" fillcolor=red];
}
50 -> {51};
subgraph cluster_15 {
color=red
52 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_16 {
color=blue
53 [label="Enter when"];
subgraph cluster_17 {
color=blue
54 [label="Enter when branch condition "];
55 [label="Access variable R|<local>/x|"];
56 [label="Type operator: (R|<local>/x| is R|B|)"];
57 [label="Exit when branch condition"];
}
subgraph cluster_18 {
color=blue
58 [label="Enter when branch condition "];
59 [label="Access variable R|<local>/x|"];
60 [label="Type operator: (R|<local>/x| is R|C|)"];
61 [label="Exit when branch condition"];
}
subgraph cluster_19 {
color=blue
62 [label="Enter when branch condition else"];
63 [label="Exit when branch condition"];
}
64 [label="Enter when branch result"];
subgraph cluster_20 {
color=blue
65 [label="Enter block"];
66 [label="Jump: ^test_2 Unit"];
67 [label="Stub" style="filled" fillcolor=gray];
68 [label="Exit block" style="filled" fillcolor=gray];
}
69 [label="Exit when branch result" style="filled" fillcolor=gray];
70 [label="Enter when branch result"];
subgraph cluster_21 {
color=blue
71 [label="Enter block"];
72 [label="Access variable R|<local>/x|"];
73 [label="Function call: R|<local>/x|.R|/C.baz|()"];
74 [label="Exit block"];
}
75 [label="Exit when branch result"];
76 [label="Enter when branch result"];
subgraph cluster_22 {
color=blue
77 [label="Enter block"];
78 [label="Access variable R|<local>/x|"];
79 [label="Function call: R|<local>/x|.R|/B.bar|()"];
80 [label="Exit block"];
}
81 [label="Exit when branch result"];
82 [label="Exit when"];
}
83 [label="Access variable R|<local>/x|"];
84 [label="Function call: R|<local>/x|.R|/A.foo|()"];
85 [label="Access variable R|<local>/x|"];
86 [label="Function call: R|<local>/x|.<Unresolved name: bar>#()"];
87 [label="Access variable R|<local>/x|"];
88 [label="Function call: R|<local>/x|.<Unresolved name: baz>#()"];
89 [label="Exit function test_2" style="filled" fillcolor=red];
}
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {76 58};
58 -> {59};
59 -> {60};
60 -> {61};
61 -> {70 62};
62 -> {63};
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {89};
66 -> {67} [style=dotted];
67 -> {68} [style=dotted];
68 -> {69} [style=dotted];
69 -> {82} [style=dotted];
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {74};
74 -> {75};
75 -> {82};
76 -> {77};
77 -> {78};
78 -> {79};
79 -> {80};
80 -> {81};
81 -> {82};
82 -> {83};
83 -> {84};
84 -> {85};
85 -> {86};
86 -> {87};
87 -> {88};
88 -> {89};
subgraph cluster_23 {
color=red
90 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_24 {
color=blue
91 [label="Enter when"];
subgraph cluster_25 {
color=blue
92 [label="Enter when branch condition "];
93 [label="Access variable R|<local>/x|"];
94 [label="Type operator: (R|<local>/x| is R|B|)"];
95 [label="Exit when branch condition"];
}
subgraph cluster_26 {
color=blue
96 [label="Enter when branch condition "];
97 [label="Access variable R|<local>/x|"];
98 [label="Type operator: (R|<local>/x| is R|C|)"];
99 [label="Exit when branch condition"];
}
100 [label="Synthetic else branch"];
101 [label="Enter when branch result"];
subgraph cluster_27 {
color=blue
102 [label="Enter block"];
103 [label="Access variable R|<local>/x|"];
104 [label="Function call: R|<local>/x|.R|/C.baz|()"];
105 [label="Exit block"];
}
106 [label="Exit when branch result"];
107 [label="Enter when branch result"];
subgraph cluster_28 {
color=blue
108 [label="Enter block"];
109 [label="Access variable R|<local>/x|"];
110 [label="Function call: R|<local>/x|.R|/B.bar|()"];
111 [label="Exit block"];
}
112 [label="Exit when branch result"];
113 [label="Exit when"];
}
114 [label="Access variable R|<local>/x|"];
115 [label="Function call: R|<local>/x|.<Unresolved name: foo>#()"];
116 [label="Access variable R|<local>/x|"];
117 [label="Function call: R|<local>/x|.<Unresolved name: bar>#()"];
118 [label="Access variable R|<local>/x|"];
119 [label="Function call: R|<local>/x|.<Unresolved name: baz>#()"];
120 [label="Exit function test_3" style="filled" fillcolor=red];
}
90 -> {91};
91 -> {92};
92 -> {93};
93 -> {94};
94 -> {95};
95 -> {107 96};
96 -> {97};
97 -> {98};
98 -> {99};
99 -> {101 100};
100 -> {113};
101 -> {102};
102 -> {103};
103 -> {104};
104 -> {105};
105 -> {106};
106 -> {113};
107 -> {108};
108 -> {109};
109 -> {110};
110 -> {111};
111 -> {112};
112 -> {113};
113 -> {114};
114 -> {115};
115 -> {116};
116 -> {117};
117 -> {118};
118 -> {119};
119 -> {120};
subgraph cluster_29 {
color=red
121 [label="Enter function runHigherOrder" style="filled" fillcolor=red];
122 [label="Function call: R|<local>/f|.R|FakeOverride<kotlin/Function0.invoke: R|T|>|()"];
123 [label="Jump: ^runHigherOrder R|<local>/f|.R|FakeOverride<kotlin/Function0.invoke: R|T|>|()"];
124 [label="Stub" style="filled" fillcolor=gray];
125 [label="Exit function runHigherOrder" style="filled" fillcolor=red];
}
121 -> {122};
122 -> {123};
123 -> {125};
123 -> {124} [style=dotted];
124 -> {125} [style=dotted];
subgraph cluster_30 {
color=red
126 [label="Enter function getter" style="filled" fillcolor=red];
127 [label="Access variable R|kotlin/String.length|"];
128 [label="Jump: ^ this@R|/ext|.R|kotlin/String.length|"];
129 [label="Stub" style="filled" fillcolor=gray];
130 [label="Exit function getter" style="filled" fillcolor=red];
}
126 -> {127};
127 -> {128};
128 -> {130};
128 -> {129} [style=dotted];
129 -> {130} [style=dotted];
subgraph cluster_31 {
color=red
131 [label="Enter property" style="filled" fillcolor=red];
132 [label="Exit property" style="filled" fillcolor=red];
}
131 -> {132};
subgraph cluster_32 {
color=red
133 [label="Enter function test_4" style="filled" fillcolor=red];
134 [label="Access variable R|<local>/a|"];
135 [label="Type operator: (R|<local>/a| as? R|kotlin/String|)"];
136 [label="Variable declaration: lval s: R|kotlin/String?|"];
subgraph cluster_33 {
color=blue
137 [label="Enter when"];
138 [label="Access variable R|<local>/s|"];
139 [label="Enter safe call"];
140 [label="Access variable R|/ext|"];
141 [label="Exit safe call"];
142 [label="Variable declaration: lval <elvis>: R|kotlin/Int?|"];
subgraph cluster_34 {
color=blue
143 [label="Enter when branch condition "];
144 [label="Const: Null(null)"];
145 [label="Operator =="];
146 [label="Exit when branch condition"];
}
subgraph cluster_35 {
color=blue
147 [label="Enter when branch condition else"];
148 [label="Exit when branch condition"];
}
149 [label="Enter when branch result"];
subgraph cluster_36 {
color=blue
150 [label="Enter block"];
151 [label="Access variable R|<local>/<elvis>|"];
152 [label="Exit block"];
}
153 [label="Exit when branch result"];
154 [label="Enter when branch result"];
subgraph cluster_37 {
color=blue
155 [label="Enter block"];
156 [label="Jump: ^test_4 Unit"];
157 [label="Stub" style="filled" fillcolor=gray];
158 [label="Exit block" style="filled" fillcolor=gray];
}
159 [label="Exit when branch result" style="filled" fillcolor=gray];
160 [label="Exit when"];
}
161 [label="Variable declaration: lval length: R|kotlin/Int|"];
162 [label="Postponed enter to lambda"];
163 [label="Postponed exit from lambda"];
164 [label="Function call: R|/runHigherOrder|<R|kotlin/Int|>(...)"];
165 [label="Exit function test_4" style="filled" fillcolor=red];
}
133 -> {134};
134 -> {135};
135 -> {136};
136 -> {137};
137 -> {138};
138 -> {139 141};
139 -> {140};
140 -> {141};
141 -> {142};
142 -> {143};
143 -> {144};
144 -> {145};
145 -> {146};
146 -> {154 147};
147 -> {148};
148 -> {149};
149 -> {150};
150 -> {151};
151 -> {152};
152 -> {153};
153 -> {160};
154 -> {155};
155 -> {156};
156 -> {165};
156 -> {157} [style=dotted];
157 -> {158} [style=dotted];
158 -> {159} [style=dotted];
159 -> {160} [style=dotted];
160 -> {161};
161 -> {162};
162 -> {163 163} [color=green];
163 -> {164};
164 -> {165};
subgraph cluster_38 {
color=red
166 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
167 [label="Access variable R|<local>/s|"];
168 [label="Access variable R|kotlin/String.length|"];
169 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
166 -> {167};
167 -> {168};
168 -> {169};
}
@@ -0,0 +1,63 @@
// !DUMP_CFG
fun test_0(x: Any) {
if (x is String) {
x.length
} else {
}
x.<!UNRESOLVED_REFERENCE!>length<!>
}
fun test_1(x: Any) {
if (x is String) {
x.length
} else {
return
}
x.length
}
interface A {
fun foo()
}
interface B : A {
fun bar()
}
interface C : A {
fun baz()
}
fun test_2(x: Any) {
when {
x is B -> x.bar()
x is C -> x.baz()
else -> return
}
x.foo()
x.<!UNRESOLVED_REFERENCE!>bar<!>()
x.<!UNRESOLVED_REFERENCE!>baz<!>()
}
fun test_3(x: Any) {
when {
x is B -> x.bar()
x is C -> x.baz()
}
x.<!UNRESOLVED_REFERENCE!>foo<!>()
x.<!UNRESOLVED_REFERENCE!>bar<!>()
x.<!UNRESOLVED_REFERENCE!>baz<!>()
}
fun <T> runHigherOrder(f: () -> T): T = f()
val String.ext: Int get() = length
fun test_4(a: Any?) {
val s = a as? String
val length = s?.ext ?: return
runHigherOrder {
s.length // Should be OK
}
}
@@ -0,0 +1,90 @@
FILE: returns.kt
public final fun test_0(x: R|kotlin/Any|): R|kotlin/Unit| {
when () {
(R|<local>/x| is R|kotlin/String|) -> {
R|<local>/x|.R|kotlin/String.length|
}
else -> {
}
}
R|<local>/x|.<Unresolved name: length>#
}
public final fun test_1(x: R|kotlin/Any|): R|kotlin/Unit| {
when () {
(R|<local>/x| is R|kotlin/String|) -> {
R|<local>/x|.R|kotlin/String.length|
}
else -> {
^test_1 Unit
}
}
R|<local>/x|.R|kotlin/String.length|
}
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Unit|
}
public abstract interface B : R|A| {
public abstract fun bar(): R|kotlin/Unit|
}
public abstract interface C : R|A| {
public abstract fun baz(): R|kotlin/Unit|
}
public final fun test_2(x: R|kotlin/Any|): R|kotlin/Unit| {
when () {
(R|<local>/x| is R|B|) -> {
R|<local>/x|.R|/B.bar|()
}
(R|<local>/x| is R|C|) -> {
R|<local>/x|.R|/C.baz|()
}
else -> {
^test_2 Unit
}
}
R|<local>/x|.R|/A.foo|()
R|<local>/x|.<Unresolved name: bar>#()
R|<local>/x|.<Unresolved name: baz>#()
}
public final fun test_3(x: R|kotlin/Any|): R|kotlin/Unit| {
when () {
(R|<local>/x| is R|B|) -> {
R|<local>/x|.R|/B.bar|()
}
(R|<local>/x| is R|C|) -> {
R|<local>/x|.R|/C.baz|()
}
}
R|<local>/x|.<Unresolved name: foo>#()
R|<local>/x|.<Unresolved name: bar>#()
R|<local>/x|.<Unresolved name: baz>#()
}
public final fun <T> runHigherOrder(f: R|() -> T|): R|T| {
^runHigherOrder R|<local>/f|.R|FakeOverride<kotlin/Function0.invoke: R|T|>|()
}
public final val R|kotlin/String|.ext: R|kotlin/Int|
public get(): R|kotlin/Int| {
^ this@R|/ext|.R|kotlin/String.length|
}
public final fun test_4(a: R|kotlin/Any?|): R|kotlin/Unit| {
lval s: R|kotlin/String?| = (R|<local>/a| as? R|kotlin/String|)
lval length: R|kotlin/Int| = when (lval <elvis>: R|kotlin/Int?| = R|<local>/s|?.R|/ext|) {
==($subj$, Null(null)) -> {
^test_4 Unit
}
else -> {
R|<local>/<elvis>|
}
}
R|/runHigherOrder|<R|kotlin/Int|>(<L> = runHigherOrder@fun <anonymous>(): R|kotlin/Int| {
^ R|<local>/s|.R|kotlin/String.length|
}
)
}
@@ -0,0 +1,189 @@
digraph simpleIf_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_1 {
color=blue
1 [label="Enter when"];
subgraph cluster_2 {
color=blue
2 [label="Enter when branch condition "];
3 [label="Access variable R|<local>/x|"];
4 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
5 [label="Exit when branch condition"];
}
6 [label="Synthetic else branch"];
7 [label="Enter when branch result"];
subgraph cluster_3 {
color=blue
8 [label="Enter block"];
9 [label="Access variable R|<local>/x|"];
10 [label="Access variable R|kotlin/String.length|"];
11 [label="Exit block"];
}
12 [label="Exit when branch result"];
13 [label="Exit when"];
}
14 [label="Access variable R|<local>/x|"];
15 [label="Access variable <Unresolved name: length>#"];
16 [label="Exit function test_1" style="filled" fillcolor=red];
}
0 -> {1};
1 -> {2};
2 -> {3};
3 -> {4};
4 -> {5};
5 -> {7 6};
6 -> {13};
7 -> {8};
8 -> {9};
9 -> {10};
10 -> {11};
11 -> {12};
12 -> {13};
13 -> {14};
14 -> {15};
15 -> {16};
subgraph cluster_4 {
color=red
17 [label="Enter function test_2" style="filled" fillcolor=red];
18 [label="Access variable R|<local>/x|"];
19 [label="Type operator: (R|<local>/x| is R|kotlin/String|)"];
20 [label="Variable declaration: lval b: R|kotlin/Boolean|"];
subgraph cluster_5 {
color=blue
21 [label="Enter when"];
subgraph cluster_6 {
color=blue
22 [label="Enter when branch condition "];
23 [label="Access variable R|<local>/b|"];
24 [label="Exit when branch condition"];
}
25 [label="Synthetic else branch"];
26 [label="Enter when branch result"];
subgraph cluster_7 {
color=blue
27 [label="Enter block"];
28 [label="Access variable R|<local>/x|"];
29 [label="Access variable R|kotlin/String.length|"];
30 [label="Exit block"];
}
31 [label="Exit when branch result"];
32 [label="Exit when"];
}
33 [label="Access variable R|<local>/x|"];
34 [label="Access variable <Unresolved name: length>#"];
35 [label="Exit function test_2" style="filled" fillcolor=red];
}
17 -> {18};
18 -> {19};
19 -> {20};
20 -> {21};
21 -> {22};
22 -> {23};
23 -> {24};
24 -> {26 25};
25 -> {32};
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {33};
33 -> {34};
34 -> {35};
subgraph cluster_8 {
color=red
36 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_9 {
color=blue
37 [label="Enter when"];
subgraph cluster_10 {
color=blue
38 [label="Enter when branch condition "];
39 [label="Access variable R|<local>/x|"];
40 [label="Type operator: (R|<local>/x| !is R|kotlin/String|)"];
41 [label="Exit when branch condition"];
}
subgraph cluster_11 {
color=blue
42 [label="Enter when branch condition "];
43 [label="Access variable R|<local>/x|"];
44 [label="Type operator: (R|<local>/x| !is R|kotlin/Int|)"];
45 [label="Exit when branch condition"];
}
subgraph cluster_12 {
color=blue
46 [label="Enter when branch condition else"];
47 [label="Exit when branch condition"];
}
48 [label="Enter when branch result"];
subgraph cluster_13 {
color=blue
49 [label="Enter block"];
50 [label="Access variable R|<local>/x|"];
51 [label="Access variable R|kotlin/String.length|"];
52 [label="Access variable R|<local>/x|"];
53 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
54 [label="Exit block"];
}
55 [label="Exit when branch result"];
56 [label="Enter when branch result"];
subgraph cluster_14 {
color=blue
57 [label="Enter block"];
58 [label="Exit block"];
}
59 [label="Exit when branch result"];
60 [label="Enter when branch result"];
subgraph cluster_15 {
color=blue
61 [label="Enter block"];
62 [label="Exit block"];
}
63 [label="Exit when branch result"];
64 [label="Exit when"];
}
65 [label="Exit function test_3" style="filled" fillcolor=red];
}
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {60 42};
42 -> {43};
43 -> {44};
44 -> {45};
45 -> {56 46};
46 -> {47};
47 -> {48};
48 -> {49};
49 -> {50};
50 -> {51};
51 -> {52};
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {64};
56 -> {57};
57 -> {58};
58 -> {59};
59 -> {64};
60 -> {61};
61 -> {62};
62 -> {63};
63 -> {64};
64 -> {65};
}
@@ -0,0 +1,26 @@
// !DUMP_CFG
fun test_1(x: Any) {
if (x is String) {
x.length
}
x.<!UNRESOLVED_REFERENCE!>length<!>
}
fun test_2(x: Any) {
val b = x is String
if (b) {
x.length
}
x.<!UNRESOLVED_REFERENCE!>length<!>
}
fun test_3(x: Any) {
when {
x !is String -> {}
x !is Int -> {}
else -> {
x.length
x.inc()
}
}
}
@@ -0,0 +1,33 @@
FILE: simpleIf.kt
public final fun test_1(x: R|kotlin/Any|): R|kotlin/Unit| {
when () {
(R|<local>/x| is R|kotlin/String|) -> {
R|<local>/x|.R|kotlin/String.length|
}
}
R|<local>/x|.<Unresolved name: length>#
}
public final fun test_2(x: R|kotlin/Any|): R|kotlin/Unit| {
lval b: R|kotlin/Boolean| = (R|<local>/x| is R|kotlin/String|)
when () {
R|<local>/b| -> {
R|<local>/x|.R|kotlin/String.length|
}
}
R|<local>/x|.<Unresolved name: length>#
}
public final fun test_3(x: R|kotlin/Any|): R|kotlin/Unit| {
when () {
(R|<local>/x| !is R|kotlin/String|) -> {
}
(R|<local>/x| !is R|kotlin/Int|) -> {
}
else -> {
R|<local>/x|.R|kotlin/String.length|
R|<local>/x|.R|kotlin/Int.inc|()
}
}
}
@@ -0,0 +1,130 @@
digraph smartcastFromArgument_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function foo" style="filled" fillcolor=red];
1 [label="Exit function foo" style="filled" fillcolor=red];
}
0 -> {1};
subgraph cluster_1 {
color=red
2 [label="Enter function takeA" style="filled" fillcolor=red];
3 [label="Const: Boolean(true)"];
4 [label="Jump: ^takeA Boolean(true)"];
5 [label="Stub" style="filled" fillcolor=gray];
6 [label="Exit function takeA" style="filled" fillcolor=red];
}
2 -> {3};
3 -> {4};
4 -> {6};
4 -> {5} [style=dotted];
5 -> {6} [style=dotted];
subgraph cluster_2 {
color=red
7 [label="Enter function test" style="filled" fillcolor=red];
subgraph cluster_3 {
color=blue
8 [label="Enter when"];
subgraph cluster_4 {
color=blue
9 [label="Enter when branch condition "];
subgraph cluster_5 {
color=blue
10 [label="Enter when"];
11 [label="Access variable R|<local>/a|"];
12 [label="Type operator: (R|<local>/a| as? R|A|)"];
13 [label="Variable declaration: lval <elvis>: R|A?|"];
subgraph cluster_6 {
color=blue
14 [label="Enter when branch condition "];
15 [label="Const: Null(null)"];
16 [label="Operator =="];
17 [label="Exit when branch condition"];
}
subgraph cluster_7 {
color=blue
18 [label="Enter when branch condition else"];
19 [label="Exit when branch condition"];
}
20 [label="Enter when branch result"];
subgraph cluster_8 {
color=blue
21 [label="Enter block"];
22 [label="Access variable R|<local>/<elvis>|"];
23 [label="Exit block"];
}
24 [label="Exit when branch result"];
25 [label="Enter when branch result"];
subgraph cluster_9 {
color=blue
26 [label="Enter block"];
27 [label="Jump: ^test Unit"];
28 [label="Stub" style="filled" fillcolor=gray];
29 [label="Exit block" style="filled" fillcolor=gray];
}
30 [label="Exit when branch result" style="filled" fillcolor=gray];
31 [label="Exit when"];
}
32 [label="Function call: R|/takeA|(...)"];
33 [label="Exit when branch condition"];
}
34 [label="Synthetic else branch"];
35 [label="Enter when branch result"];
subgraph cluster_10 {
color=blue
36 [label="Enter block"];
37 [label="Access variable R|<local>/a|"];
38 [label="Function call: R|<local>/a|.R|/A.foo|()"];
39 [label="Exit block"];
}
40 [label="Exit when branch result"];
41 [label="Exit when"];
}
42 [label="Exit function test" style="filled" fillcolor=red];
}
7 -> {8};
8 -> {9};
9 -> {10};
10 -> {11};
11 -> {12};
12 -> {13};
13 -> {14};
14 -> {15};
15 -> {16};
16 -> {17};
17 -> {25 18};
18 -> {19};
19 -> {20};
20 -> {21};
21 -> {22};
22 -> {23};
23 -> {24};
24 -> {31};
25 -> {26};
26 -> {27};
27 -> {42};
27 -> {28} [style=dotted];
28 -> {29} [style=dotted];
29 -> {30} [style=dotted];
30 -> {31} [style=dotted];
31 -> {32};
32 -> {33};
33 -> {35 34};
34 -> {41};
35 -> {36};
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {42};
}
@@ -0,0 +1,12 @@
// !DUMP_CFG
interface A {
fun foo()
}
fun takeA(a: A): Boolean = true
fun test(a: Any) {
if (takeA(a as? A ?: return)) {
a.foo()
}
}
@@ -0,0 +1,24 @@
FILE: smartcastFromArgument.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Unit|
}
public final fun takeA(a: R|A|): R|kotlin/Boolean| {
^takeA Boolean(true)
}
public final fun test(a: R|kotlin/Any|): R|kotlin/Unit| {
when () {
R|/takeA|(when (lval <elvis>: R|A?| = (R|<local>/a| as? R|A|)) {
==($subj$, Null(null)) -> {
^test Unit
}
else -> {
R|<local>/<elvis>|
}
}
) -> {
R|<local>/a|.R|/A.foo|()
}
}
}
@@ -0,0 +1,649 @@
digraph when_kt {
graph [nodesep=3]
node [shape=box penwidth=2]
edge [penwidth=2]
subgraph cluster_0 {
color=red
0 [label="Enter function foo" style="filled" fillcolor=red];
1 [label="Exit function foo" style="filled" fillcolor=red];
}
0 -> {1};
subgraph cluster_1 {
color=red
2 [label="Enter function bar" style="filled" fillcolor=red];
3 [label="Exit function bar" style="filled" fillcolor=red];
}
2 -> {3};
subgraph cluster_2 {
color=red
4 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_3 {
color=blue
5 [label="Enter when"];
subgraph cluster_4 {
color=blue
6 [label="Enter when branch condition "];
7 [label="Access variable R|<local>/x|"];
8 [label="Type operator: (R|<local>/x| is R|A|)"];
9 [label="Exit when branch condition"];
}
subgraph cluster_5 {
color=blue
10 [label="Enter when branch condition "];
11 [label="Access variable R|<local>/x|"];
12 [label="Type operator: (R|<local>/x| is R|B|)"];
13 [label="Exit when branch condition"];
}
14 [label="Synthetic else branch"];
15 [label="Enter when branch result"];
subgraph cluster_6 {
color=blue
16 [label="Enter block"];
17 [label="Access variable R|<local>/x|"];
18 [label="Function call: R|<local>/x|.R|/B.bar|()"];
19 [label="Exit block"];
}
20 [label="Exit when branch result"];
21 [label="Enter when branch result"];
subgraph cluster_7 {
color=blue
22 [label="Enter block"];
23 [label="Access variable R|<local>/x|"];
24 [label="Function call: R|<local>/x|.R|/A.foo|()"];
25 [label="Exit block"];
}
26 [label="Exit when branch result"];
27 [label="Exit when"];
}
subgraph cluster_8 {
color=blue
28 [label="Enter when"];
subgraph cluster_9 {
color=blue
29 [label="Enter when branch condition "];
30 [label="Access variable R|<local>/x|"];
31 [label="Type operator: (R|<local>/x| !is R|A|)"];
32 [label="Exit when branch condition"];
}
subgraph cluster_10 {
color=blue
33 [label="Enter when branch condition "];
34 [label="Access variable R|<local>/x|"];
35 [label="Type operator: (R|<local>/x| !is R|B|)"];
36 [label="Exit when branch condition"];
}
subgraph cluster_11 {
color=blue
37 [label="Enter when branch condition "];
38 [label="Access variable R|<local>/x|"];
39 [label="Type operator: (R|<local>/x| is R|kotlin/Int|)"];
40 [label="Exit when branch condition"];
}
subgraph cluster_12 {
color=blue
41 [label="Enter when branch condition else"];
42 [label="Exit when branch condition"];
}
43 [label="Enter when branch result"];
subgraph cluster_13 {
color=blue
44 [label="Enter block"];
45 [label="Access variable R|<local>/x|"];
46 [label="Function call: R|<local>/x|.R|/A.foo|()"];
47 [label="Access variable R|<local>/x|"];
48 [label="Function call: R|<local>/x|.R|/B.bar|()"];
49 [label="Exit block"];
}
50 [label="Exit when branch result"];
51 [label="Enter when branch result"];
subgraph cluster_14 {
color=blue
52 [label="Enter block"];
53 [label="Access variable R|<local>/x|"];
54 [label="Function call: R|<local>/x|.R|/A.foo|()"];
55 [label="Access variable R|<local>/x|"];
56 [label="Function call: R|<local>/x|.R|/B.bar|()"];
57 [label="Access variable R|<local>/x|"];
58 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
59 [label="Exit block"];
}
60 [label="Exit when branch result"];
61 [label="Enter when branch result"];
subgraph cluster_15 {
color=blue
62 [label="Enter block"];
63 [label="Access variable R|<local>/x|"];
64 [label="Function call: R|<local>/x|.R|/A.foo|()"];
65 [label="Exit block"];
}
66 [label="Exit when branch result"];
67 [label="Enter when branch result"];
subgraph cluster_16 {
color=blue
68 [label="Enter block"];
69 [label="Exit block"];
}
70 [label="Exit when branch result"];
71 [label="Exit when"];
}
72 [label="Exit function test_1" style="filled" fillcolor=red];
}
4 -> {5};
5 -> {6};
6 -> {7};
7 -> {8};
8 -> {9};
9 -> {21 10};
10 -> {11};
11 -> {12};
12 -> {13};
13 -> {15 14};
14 -> {27};
15 -> {16};
16 -> {17};
17 -> {18};
18 -> {19};
19 -> {20};
20 -> {27};
21 -> {22};
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {26};
26 -> {27};
27 -> {28};
28 -> {29};
29 -> {30};
30 -> {31};
31 -> {32};
32 -> {67 33};
33 -> {34};
34 -> {35};
35 -> {36};
36 -> {61 37};
37 -> {38};
38 -> {39};
39 -> {40};
40 -> {51 41};
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {45};
45 -> {46};
46 -> {47};
47 -> {48};
48 -> {49};
49 -> {50};
50 -> {71};
51 -> {52};
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {56};
56 -> {57};
57 -> {58};
58 -> {59};
59 -> {60};
60 -> {71};
61 -> {62};
62 -> {63};
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {71};
67 -> {68};
68 -> {69};
69 -> {70};
70 -> {71};
71 -> {72};
subgraph cluster_17 {
color=red
73 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_18 {
color=blue
74 [label="Enter when"];
75 [label="Access variable R|<local>/x|"];
subgraph cluster_19 {
color=blue
76 [label="Enter when branch condition "];
77 [label="Type operator: ($subj$ is R|A|)"];
78 [label="Exit when branch condition"];
}
subgraph cluster_20 {
color=blue
79 [label="Enter when branch condition "];
80 [label="Type operator: ($subj$ is R|B|)"];
81 [label="Exit when branch condition"];
}
82 [label="Synthetic else branch"];
83 [label="Enter when branch result"];
subgraph cluster_21 {
color=blue
84 [label="Enter block"];
85 [label="Access variable R|<local>/x|"];
86 [label="Function call: R|<local>/x|.R|/B.bar|()"];
87 [label="Exit block"];
}
88 [label="Exit when branch result"];
89 [label="Enter when branch result"];
subgraph cluster_22 {
color=blue
90 [label="Enter block"];
91 [label="Access variable R|<local>/x|"];
92 [label="Function call: R|<local>/x|.R|/A.foo|()"];
93 [label="Exit block"];
}
94 [label="Exit when branch result"];
95 [label="Exit when"];
}
subgraph cluster_23 {
color=blue
96 [label="Enter when"];
97 [label="Access variable R|<local>/x|"];
subgraph cluster_24 {
color=blue
98 [label="Enter when branch condition "];
99 [label="Type operator: ($subj$ !is R|A|)"];
100 [label="Exit when branch condition"];
}
subgraph cluster_25 {
color=blue
101 [label="Enter when branch condition "];
102 [label="Type operator: ($subj$ !is R|B|)"];
103 [label="Exit when branch condition"];
}
subgraph cluster_26 {
color=blue
104 [label="Enter when branch condition "];
105 [label="Type operator: ($subj$ is R|kotlin/Int|)"];
106 [label="Exit when branch condition"];
}
subgraph cluster_27 {
color=blue
107 [label="Enter when branch condition else"];
108 [label="Exit when branch condition"];
}
109 [label="Enter when branch result"];
subgraph cluster_28 {
color=blue
110 [label="Enter block"];
111 [label="Access variable R|<local>/x|"];
112 [label="Function call: R|<local>/x|.R|/A.foo|()"];
113 [label="Access variable R|<local>/x|"];
114 [label="Function call: R|<local>/x|.R|/B.bar|()"];
115 [label="Exit block"];
}
116 [label="Exit when branch result"];
117 [label="Enter when branch result"];
subgraph cluster_29 {
color=blue
118 [label="Enter block"];
119 [label="Access variable R|<local>/x|"];
120 [label="Function call: R|<local>/x|.R|/A.foo|()"];
121 [label="Access variable R|<local>/x|"];
122 [label="Function call: R|<local>/x|.R|/B.bar|()"];
123 [label="Access variable R|<local>/x|"];
124 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
125 [label="Exit block"];
}
126 [label="Exit when branch result"];
127 [label="Enter when branch result"];
subgraph cluster_30 {
color=blue
128 [label="Enter block"];
129 [label="Access variable R|<local>/x|"];
130 [label="Function call: R|<local>/x|.R|/A.foo|()"];
131 [label="Exit block"];
}
132 [label="Exit when branch result"];
133 [label="Enter when branch result"];
subgraph cluster_31 {
color=blue
134 [label="Enter block"];
135 [label="Exit block"];
}
136 [label="Exit when branch result"];
137 [label="Exit when"];
}
138 [label="Exit function test_2" style="filled" fillcolor=red];
}
73 -> {74};
74 -> {75};
75 -> {76};
76 -> {77};
77 -> {78};
78 -> {89 79};
79 -> {80};
80 -> {81};
81 -> {83 82};
82 -> {95};
83 -> {84};
84 -> {85};
85 -> {86};
86 -> {87};
87 -> {88};
88 -> {95};
89 -> {90};
90 -> {91};
91 -> {92};
92 -> {93};
93 -> {94};
94 -> {95};
95 -> {96};
96 -> {97};
97 -> {98};
98 -> {99};
99 -> {100};
100 -> {133 101};
101 -> {102};
102 -> {103};
103 -> {127 104};
104 -> {105};
105 -> {106};
106 -> {117 107};
107 -> {108};
108 -> {109};
109 -> {110};
110 -> {111};
111 -> {112};
112 -> {113};
113 -> {114};
114 -> {115};
115 -> {116};
116 -> {137};
117 -> {118};
118 -> {119};
119 -> {120};
120 -> {121};
121 -> {122};
122 -> {123};
123 -> {124};
124 -> {125};
125 -> {126};
126 -> {137};
127 -> {128};
128 -> {129};
129 -> {130};
130 -> {131};
131 -> {132};
132 -> {137};
133 -> {134};
134 -> {135};
135 -> {136};
136 -> {137};
137 -> {138};
subgraph cluster_32 {
color=red
139 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_33 {
color=blue
140 [label="Enter when"];
141 [label="Access variable R|<local>/x|"];
142 [label="Variable declaration: lval y: R|kotlin/Any?|"];
subgraph cluster_34 {
color=blue
143 [label="Enter when branch condition "];
144 [label="Type operator: ($subj$ is R|A|)"];
145 [label="Exit when branch condition"];
}
subgraph cluster_35 {
color=blue
146 [label="Enter when branch condition "];
147 [label="Type operator: ($subj$ is R|B|)"];
148 [label="Exit when branch condition"];
}
149 [label="Synthetic else branch"];
150 [label="Enter when branch result"];
subgraph cluster_36 {
color=blue
151 [label="Enter block"];
152 [label="Access variable R|<local>/x|"];
153 [label="Function call: R|<local>/x|.R|/B.bar|()"];
154 [label="Access variable R|<local>/y|"];
155 [label="Function call: R|<local>/y|.R|/B.bar|()"];
156 [label="Exit block"];
}
157 [label="Exit when branch result"];
158 [label="Enter when branch result"];
subgraph cluster_37 {
color=blue
159 [label="Enter block"];
160 [label="Access variable R|<local>/x|"];
161 [label="Function call: R|<local>/x|.R|/A.foo|()"];
162 [label="Access variable R|<local>/y|"];
163 [label="Function call: R|<local>/y|.R|/A.foo|()"];
164 [label="Exit block"];
}
165 [label="Exit when branch result"];
166 [label="Exit when"];
}
subgraph cluster_38 {
color=blue
167 [label="Enter when"];
168 [label="Access variable R|<local>/x|"];
169 [label="Variable declaration: lval y: R|kotlin/Any?|"];
subgraph cluster_39 {
color=blue
170 [label="Enter when branch condition "];
171 [label="Type operator: ($subj$ !is R|A|)"];
172 [label="Exit when branch condition"];
}
subgraph cluster_40 {
color=blue
173 [label="Enter when branch condition "];
174 [label="Type operator: ($subj$ !is R|B|)"];
175 [label="Exit when branch condition"];
}
subgraph cluster_41 {
color=blue
176 [label="Enter when branch condition "];
177 [label="Type operator: ($subj$ is R|kotlin/Int|)"];
178 [label="Exit when branch condition"];
}
subgraph cluster_42 {
color=blue
179 [label="Enter when branch condition else"];
180 [label="Exit when branch condition"];
}
181 [label="Enter when branch result"];
subgraph cluster_43 {
color=blue
182 [label="Enter block"];
183 [label="Access variable R|<local>/x|"];
184 [label="Function call: R|<local>/x|.R|/A.foo|()"];
185 [label="Access variable R|<local>/x|"];
186 [label="Function call: R|<local>/x|.R|/B.bar|()"];
187 [label="Access variable R|<local>/y|"];
188 [label="Function call: R|<local>/y|.R|/A.foo|()"];
189 [label="Access variable R|<local>/y|"];
190 [label="Function call: R|<local>/y|.R|/B.bar|()"];
191 [label="Exit block"];
}
192 [label="Exit when branch result"];
193 [label="Enter when branch result"];
subgraph cluster_44 {
color=blue
194 [label="Enter block"];
195 [label="Access variable R|<local>/x|"];
196 [label="Function call: R|<local>/x|.R|/A.foo|()"];
197 [label="Access variable R|<local>/x|"];
198 [label="Function call: R|<local>/x|.R|/B.bar|()"];
199 [label="Access variable R|<local>/x|"];
200 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
201 [label="Access variable R|<local>/y|"];
202 [label="Function call: R|<local>/y|.R|/A.foo|()"];
203 [label="Access variable R|<local>/y|"];
204 [label="Function call: R|<local>/y|.R|/B.bar|()"];
205 [label="Access variable R|<local>/y|"];
206 [label="Function call: R|<local>/y|.R|kotlin/Int.inc|()"];
207 [label="Exit block"];
}
208 [label="Exit when branch result"];
209 [label="Enter when branch result"];
subgraph cluster_45 {
color=blue
210 [label="Enter block"];
211 [label="Access variable R|<local>/x|"];
212 [label="Function call: R|<local>/x|.R|/A.foo|()"];
213 [label="Access variable R|<local>/y|"];
214 [label="Function call: R|<local>/y|.R|/A.foo|()"];
215 [label="Exit block"];
}
216 [label="Exit when branch result"];
217 [label="Enter when branch result"];
subgraph cluster_46 {
color=blue
218 [label="Enter block"];
219 [label="Exit block"];
}
220 [label="Exit when branch result"];
221 [label="Exit when"];
}
222 [label="Exit function test_3" style="filled" fillcolor=red];
}
139 -> {140};
140 -> {141};
141 -> {142};
142 -> {143};
143 -> {144};
144 -> {145};
145 -> {158 146};
146 -> {147};
147 -> {148};
148 -> {150 149};
149 -> {166};
150 -> {151};
151 -> {152};
152 -> {153};
153 -> {154};
154 -> {155};
155 -> {156};
156 -> {157};
157 -> {166};
158 -> {159};
159 -> {160};
160 -> {161};
161 -> {162};
162 -> {163};
163 -> {164};
164 -> {165};
165 -> {166};
166 -> {167};
167 -> {168};
168 -> {169};
169 -> {170};
170 -> {171};
171 -> {172};
172 -> {217 173};
173 -> {174};
174 -> {175};
175 -> {209 176};
176 -> {177};
177 -> {178};
178 -> {193 179};
179 -> {180};
180 -> {181};
181 -> {182};
182 -> {183};
183 -> {184};
184 -> {185};
185 -> {186};
186 -> {187};
187 -> {188};
188 -> {189};
189 -> {190};
190 -> {191};
191 -> {192};
192 -> {221};
193 -> {194};
194 -> {195};
195 -> {196};
196 -> {197};
197 -> {198};
198 -> {199};
199 -> {200};
200 -> {201};
201 -> {202};
202 -> {203};
203 -> {204};
204 -> {205};
205 -> {206};
206 -> {207};
207 -> {208};
208 -> {221};
209 -> {210};
210 -> {211};
211 -> {212};
212 -> {213};
213 -> {214};
214 -> {215};
215 -> {216};
216 -> {221};
217 -> {218};
218 -> {219};
219 -> {220};
220 -> {221};
221 -> {222};
subgraph cluster_47 {
color=red
223 [label="Enter function test_4" style="filled" fillcolor=red];
subgraph cluster_48 {
color=blue
224 [label="Enter when"];
225 [label="Access variable R|<local>/x|"];
226 [label="Type operator: (R|<local>/x| as R|kotlin/Int|)"];
subgraph cluster_49 {
color=blue
227 [label="Enter when branch condition "];
228 [label="Const: Int(1)"];
229 [label="Operator =="];
230 [label="Exit when branch condition"];
}
231 [label="Synthetic else branch"];
232 [label="Enter when branch result"];
subgraph cluster_50 {
color=blue
233 [label="Enter block"];
234 [label="Access variable R|<local>/x|"];
235 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
236 [label="Exit block"];
}
237 [label="Exit when branch result"];
238 [label="Exit when"];
}
239 [label="Access variable R|<local>/x|"];
240 [label="Function call: R|<local>/x|.R|kotlin/Int.inc|()"];
241 [label="Exit function test_4" style="filled" fillcolor=red];
}
223 -> {224};
224 -> {225};
225 -> {226};
226 -> {227};
227 -> {228};
228 -> {229};
229 -> {230};
230 -> {232 231};
231 -> {238};
232 -> {233};
233 -> {234};
234 -> {235};
235 -> {236};
236 -> {237};
237 -> {238};
238 -> {239};
239 -> {240};
240 -> {241};
}
@@ -0,0 +1,92 @@
// !DUMP_CFG
interface A {
fun foo()
}
interface B {
fun bar()
}
fun test_1(x: Any?) {
when {
x is A -> x.foo()
x is B -> x.bar()
}
when {
x !is A -> {}
x !is B -> x.foo()
x is Int -> {
x.foo()
x.bar()
x.inc()
}
else -> {
x.foo()
x.bar()
}
}
}
fun test_2(x: Any?) {
when(x) {
is A -> x.foo()
is B -> x.bar()
}
when(x) {
!is A -> {}
!is B -> x.foo()
is Int -> {
x.foo()
x.bar()
x.inc()
}
else -> {
x.foo()
x.bar()
}
}
}
fun test_3(x: Any?) {
when(val y = x) {
is A -> {
x.foo()
y.foo()
}
is B -> {
x.bar()
y.bar()
}
}
when(val y = x) {
!is A -> {}
!is B -> {
x.foo()
y.foo()
}
is Int -> {
x.foo()
x.bar()
x.inc()
y.foo()
y.bar()
y.inc()
}
else -> {
x.foo()
x.bar()
y.foo()
y.bar()
}
}
}
fun test_4(x: Any) {
when (x as Int) {
1 -> x.inc()
}
x.inc()
}
@@ -0,0 +1,110 @@
FILE: when.kt
public abstract interface A : R|kotlin/Any| {
public abstract fun foo(): R|kotlin/Unit|
}
public abstract interface B : R|kotlin/Any| {
public abstract fun bar(): R|kotlin/Unit|
}
public final fun test_1(x: R|kotlin/Any?|): R|kotlin/Unit| {
when () {
(R|<local>/x| is R|A|) -> {
R|<local>/x|.R|/A.foo|()
}
(R|<local>/x| is R|B|) -> {
R|<local>/x|.R|/B.bar|()
}
}
when () {
(R|<local>/x| !is R|A|) -> {
}
(R|<local>/x| !is R|B|) -> {
R|<local>/x|.R|/A.foo|()
}
(R|<local>/x| is R|kotlin/Int|) -> {
R|<local>/x|.R|/A.foo|()
R|<local>/x|.R|/B.bar|()
R|<local>/x|.R|kotlin/Int.inc|()
}
else -> {
R|<local>/x|.R|/A.foo|()
R|<local>/x|.R|/B.bar|()
}
}
}
public final fun test_2(x: R|kotlin/Any?|): R|kotlin/Unit| {
when (R|<local>/x|) {
($subj$ is R|A|) -> {
R|<local>/x|.R|/A.foo|()
}
($subj$ is R|B|) -> {
R|<local>/x|.R|/B.bar|()
}
}
when (R|<local>/x|) {
($subj$ !is R|A|) -> {
}
($subj$ !is R|B|) -> {
R|<local>/x|.R|/A.foo|()
}
($subj$ is R|kotlin/Int|) -> {
R|<local>/x|.R|/A.foo|()
R|<local>/x|.R|/B.bar|()
R|<local>/x|.R|kotlin/Int.inc|()
}
else -> {
R|<local>/x|.R|/A.foo|()
R|<local>/x|.R|/B.bar|()
}
}
}
public final fun test_3(x: R|kotlin/Any?|): R|kotlin/Unit| {
when (lval y: R|kotlin/Any?| = R|<local>/x|) {
($subj$ is R|A|) -> {
R|<local>/x|.R|/A.foo|()
R|<local>/y|.R|/A.foo|()
}
($subj$ is R|B|) -> {
R|<local>/x|.R|/B.bar|()
R|<local>/y|.R|/B.bar|()
}
}
when (lval y: R|kotlin/Any?| = R|<local>/x|) {
($subj$ !is R|A|) -> {
}
($subj$ !is R|B|) -> {
R|<local>/x|.R|/A.foo|()
R|<local>/y|.R|/A.foo|()
}
($subj$ is R|kotlin/Int|) -> {
R|<local>/x|.R|/A.foo|()
R|<local>/x|.R|/B.bar|()
R|<local>/x|.R|kotlin/Int.inc|()
R|<local>/y|.R|/A.foo|()
R|<local>/y|.R|/B.bar|()
R|<local>/y|.R|kotlin/Int.inc|()
}
else -> {
R|<local>/x|.R|/A.foo|()
R|<local>/x|.R|/B.bar|()
R|<local>/y|.R|/A.foo|()
R|<local>/y|.R|/B.bar|()
}
}
}
public final fun test_4(x: R|kotlin/Any|): R|kotlin/Unit| {
when ((R|<local>/x| as R|kotlin/Int|)) {
==($subj$, Int(1)) -> {
R|<local>/x|.R|kotlin/Int.inc|()
}
}
R|<local>/x|.R|kotlin/Int.inc|()
}