FIR. Refactor smart-cast representation in FIR tree

Make smart-casts non-transparent expression without delegation
to underlying FirQualifiedAccessExpression, as children delegation in
fir tree has unclear semantics
Remove two different kinds of tree nodes for smart-casts
This commit is contained in:
Simon Ogorodnik
2022-08-02 00:49:24 +02:00
committed by teamcity
parent bc9db58b3c
commit 513af2dfbc
154 changed files with 9573 additions and 9320 deletions
@@ -96,15 +96,16 @@ digraph assignSafeCall_kt {
color=blue
35 [label="Enter block"];
36 [label="Access variable R|<local>/a|"];
37 [label="Function call: R|<local>/a|.R|/A.bar|()"];
38 [label="Exit block"];
37 [label="Smart cast: R|<local>/a|"];
38 [label="Function call: R|<local>/a|.R|/A.bar|()"];
39 [label="Exit block"];
}
39 [label="Exit when branch result"];
40 [label="Exit when"];
40 [label="Exit when branch result"];
41 [label="Exit when"];
}
41 [label="Exit block"];
42 [label="Exit block"];
}
42 [label="Exit function test_1" style="filled" fillcolor=red];
43 [label="Exit function test_1" style="filled" fillcolor=red];
}
20 -> {21};
21 -> {22};
@@ -119,7 +120,7 @@ digraph assignSafeCall_kt {
30 -> {31};
31 -> {32};
32 -> {34 33};
33 -> {40};
33 -> {41};
34 -> {35};
35 -> {36};
36 -> {37};
@@ -128,49 +129,50 @@ digraph assignSafeCall_kt {
39 -> {40};
40 -> {41};
41 -> {42};
42 -> {43};
subgraph cluster_12 {
color=red
43 [label="Enter function test_2" style="filled" fillcolor=red];
44 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_13 {
color=blue
44 [label="Enter block"];
45 [label="Access variable R|<local>/a|"];
46 [label="Enter safe call"];
47 [label="Function call: $subj$.R|/A.foo|()"];
48 [label="Exit safe call"];
49 [label="Variable declaration: lval x: R|kotlin/Int?|"];
45 [label="Enter block"];
46 [label="Access variable R|<local>/a|"];
47 [label="Enter safe call"];
48 [label="Function call: $subj$.R|/A.foo|()"];
49 [label="Exit safe call"];
50 [label="Variable declaration: lval x: R|kotlin/Int?|"];
subgraph cluster_14 {
color=blue
50 [label="Enter when"];
51 [label="Enter when"];
subgraph cluster_15 {
color=blue
51 [label="Enter when branch condition "];
52 [label="Access variable R|<local>/x|"];
53 [label="Const: Null(null)"];
54 [label="Equality operator !="];
55 [label="Exit when branch condition"];
52 [label="Enter when branch condition "];
53 [label="Access variable R|<local>/x|"];
54 [label="Const: Null(null)"];
55 [label="Equality operator !="];
56 [label="Exit when branch condition"];
}
56 [label="Synthetic else branch"];
57 [label="Enter when branch result"];
57 [label="Synthetic else branch"];
58 [label="Enter when branch result"];
subgraph cluster_16 {
color=blue
58 [label="Enter block"];
59 [label="Access variable R|<local>/a|"];
60 [label="Function call: R|<local>/a|.R|/A.bar|()"];
61 [label="Exit block"];
59 [label="Enter block"];
60 [label="Access variable R|<local>/a|"];
61 [label="Smart cast: R|<local>/a|"];
62 [label="Function call: R|<local>/a|.R|/A.bar|()"];
63 [label="Exit block"];
}
62 [label="Exit when branch result"];
63 [label="Exit when"];
64 [label="Exit when branch result"];
65 [label="Exit when"];
}
64 [label="Exit block"];
66 [label="Exit block"];
}
65 [label="Exit function test_2" style="filled" fillcolor=red];
67 [label="Exit function test_2" style="filled" fillcolor=red];
}
43 -> {44};
44 -> {45};
45 -> {46 48};
46 -> {47};
45 -> {46};
46 -> {47 49};
47 -> {48};
48 -> {49};
49 -> {50};
@@ -179,9 +181,9 @@ digraph assignSafeCall_kt {
52 -> {53};
53 -> {54};
54 -> {55};
55 -> {57 56};
56 -> {63};
57 -> {58};
55 -> {56};
56 -> {58 57};
57 -> {65};
58 -> {59};
59 -> {60};
60 -> {61};
@@ -189,230 +191,240 @@ digraph assignSafeCall_kt {
62 -> {63};
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {67};
subgraph cluster_17 {
color=red
66 [label="Enter function test_3" style="filled" fillcolor=red];
68 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_18 {
color=blue
67 [label="Enter block"];
68 [label="Access variable R|<local>/x|"];
69 [label="Type operator: (R|<local>/x| as? R|A|)"];
70 [label="Exit lhs of ?:"];
71 [label="Enter rhs of ?:"];
72 [label="Jump: ^test_3 Unit"];
73 [label="Stub" style="filled" fillcolor=gray];
74 [label="Lhs of ?: is not null"];
75 [label="Exit ?:"];
76 [label="Variable declaration: lval a: R|A|"];
77 [label="Access variable R|<local>/a|"];
78 [label="Function call: R|<local>/a|.R|/A.foo|()"];
79 [label="Access variable R|<local>/x|"];
80 [label="Function call: R|<local>/x|.R|/A.foo|()"];
81 [label="Exit block"];
69 [label="Enter block"];
70 [label="Access variable R|<local>/x|"];
71 [label="Type operator: (R|<local>/x| as? R|A|)"];
72 [label="Exit lhs of ?:"];
73 [label="Enter rhs of ?:"];
74 [label="Jump: ^test_3 Unit"];
75 [label="Stub" style="filled" fillcolor=gray];
76 [label="Lhs of ?: is not null"];
77 [label="Exit ?:"];
78 [label="Variable declaration: lval a: R|A|"];
79 [label="Access variable R|<local>/a|"];
80 [label="Function call: R|<local>/a|.R|/A.foo|()"];
81 [label="Access variable R|<local>/x|"];
82 [label="Smart cast: R|<local>/x|"];
83 [label="Function call: R|<local>/x|.R|/A.foo|()"];
84 [label="Exit block"];
}
82 [label="Exit function test_3" style="filled" fillcolor=red];
85 [label="Exit function test_3" style="filled" fillcolor=red];
}
66 -> {67};
67 -> {68};
68 -> {69};
69 -> {70};
70 -> {74 71};
70 -> {71};
71 -> {72};
72 -> {82};
72 -> {73} [style=dotted];
73 -> {75} [style=dotted];
74 -> {75};
75 -> {76};
72 -> {76 73};
73 -> {74};
74 -> {85};
74 -> {75} [style=dotted];
75 -> {77} [style=dotted];
76 -> {77};
77 -> {78};
78 -> {79};
79 -> {80};
80 -> {81};
81 -> {82};
82 -> {83};
83 -> {84};
84 -> {85};
subgraph cluster_19 {
color=red
83 [label="Enter function foo" style="filled" fillcolor=red];
84 [label="Exit function foo" style="filled" fillcolor=red];
86 [label="Enter function foo" style="filled" fillcolor=red];
87 [label="Exit function foo" style="filled" fillcolor=red];
}
83 -> {84};
86 -> {87};
subgraph cluster_20 {
color=red
85 [label="Enter function bar" style="filled" fillcolor=red];
86 [label="Exit function bar" style="filled" fillcolor=red];
88 [label="Enter function bar" style="filled" fillcolor=red];
89 [label="Exit function bar" style="filled" fillcolor=red];
}
85 -> {86};
88 -> {89};
subgraph cluster_21 {
color=red
87 [label="Enter class B" style="filled" fillcolor=red];
88 [label="Exit class B" style="filled" fillcolor=red];
90 [label="Enter class B" style="filled" fillcolor=red];
91 [label="Exit class B" style="filled" fillcolor=red];
}
87 -> {88} [color=green];
90 -> {91} [color=green];
subgraph cluster_22 {
color=red
89 [label="Enter function test_1" style="filled" fillcolor=red];
92 [label="Enter function test_1" style="filled" fillcolor=red];
subgraph cluster_23 {
color=blue
90 [label="Enter block"];
91 [label="Access variable R|<local>/a|"];
92 [label="Enter safe call"];
93 [label="Access variable R|/B.x|"];
94 [label="Exit safe call"];
95 [label="Variable declaration: lval x: R|kotlin/Int?|"];
93 [label="Enter block"];
94 [label="Access variable R|<local>/a|"];
95 [label="Enter safe call"];
96 [label="Access variable R|/B.x|"];
97 [label="Exit safe call"];
98 [label="Variable declaration: lval x: R|kotlin/Int?|"];
subgraph cluster_24 {
color=blue
96 [label="Enter when"];
99 [label="Enter when"];
subgraph cluster_25 {
color=blue
97 [label="Enter when branch condition "];
98 [label="Access variable R|<local>/x|"];
99 [label="Const: Null(null)"];
100 [label="Equality operator !="];
101 [label="Exit when branch condition"];
100 [label="Enter when branch condition "];
101 [label="Access variable R|<local>/x|"];
102 [label="Const: Null(null)"];
103 [label="Equality operator !="];
104 [label="Exit when branch condition"];
}
102 [label="Synthetic else branch"];
103 [label="Enter when branch result"];
105 [label="Synthetic else branch"];
106 [label="Enter when branch result"];
subgraph cluster_26 {
color=blue
104 [label="Enter block"];
105 [label="Access variable R|<local>/a|"];
106 [label="Function call: R|<local>/a|.R|/B.bar|()"];
107 [label="Exit block"];
107 [label="Enter block"];
108 [label="Access variable R|<local>/a|"];
109 [label="Smart cast: R|<local>/a|"];
110 [label="Function call: R|<local>/a|.R|/B.bar|()"];
111 [label="Exit block"];
}
108 [label="Exit when branch result"];
109 [label="Exit when"];
112 [label="Exit when branch result"];
113 [label="Exit when"];
}
110 [label="Exit block"];
114 [label="Exit block"];
}
111 [label="Exit function test_1" style="filled" fillcolor=red];
115 [label="Exit function test_1" style="filled" fillcolor=red];
}
89 -> {90};
90 -> {91};
91 -> {92 94};
92 -> {93};
93 -> {94};
94 -> {95};
94 -> {95 97};
95 -> {96};
96 -> {97};
97 -> {98};
98 -> {99};
99 -> {100};
100 -> {101};
101 -> {103 102};
102 -> {109};
101 -> {102};
102 -> {103};
103 -> {104};
104 -> {105};
105 -> {106};
104 -> {106 105};
105 -> {113};
106 -> {107};
107 -> {108};
108 -> {109};
109 -> {110};
110 -> {111};
111 -> {112};
112 -> {113};
113 -> {114};
114 -> {115};
subgraph cluster_27 {
color=red
112 [label="Enter function test_2" style="filled" fillcolor=red];
116 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_28 {
color=blue
113 [label="Enter block"];
114 [label="Access variable R|<local>/a|"];
115 [label="Enter safe call"];
116 [label="Function call: $subj$.R|/B.foo|()"];
117 [label="Exit safe call"];
118 [label="Variable declaration: lval x: R|kotlin/Int?|"];
117 [label="Enter block"];
118 [label="Access variable R|<local>/a|"];
119 [label="Enter safe call"];
120 [label="Function call: $subj$.R|/B.foo|()"];
121 [label="Exit safe call"];
122 [label="Variable declaration: lval x: R|kotlin/Int?|"];
subgraph cluster_29 {
color=blue
119 [label="Enter when"];
123 [label="Enter when"];
subgraph cluster_30 {
color=blue
120 [label="Enter when branch condition "];
121 [label="Access variable R|<local>/x|"];
122 [label="Const: Null(null)"];
123 [label="Equality operator !="];
124 [label="Exit when branch condition"];
124 [label="Enter when branch condition "];
125 [label="Access variable R|<local>/x|"];
126 [label="Const: Null(null)"];
127 [label="Equality operator !="];
128 [label="Exit when branch condition"];
}
125 [label="Synthetic else branch"];
126 [label="Enter when branch result"];
129 [label="Synthetic else branch"];
130 [label="Enter when branch result"];
subgraph cluster_31 {
color=blue
127 [label="Enter block"];
128 [label="Access variable R|<local>/a|"];
129 [label="Function call: R|<local>/a|.R|/B.bar|()"];
130 [label="Exit block"];
131 [label="Enter block"];
132 [label="Access variable R|<local>/a|"];
133 [label="Smart cast: R|<local>/a|"];
134 [label="Function call: R|<local>/a|.R|/B.bar|()"];
135 [label="Exit block"];
}
131 [label="Exit when branch result"];
132 [label="Exit when"];
136 [label="Exit when branch result"];
137 [label="Exit when"];
}
133 [label="Exit block"];
138 [label="Exit block"];
}
134 [label="Exit function test_2" style="filled" fillcolor=red];
139 [label="Exit function test_2" style="filled" fillcolor=red];
}
112 -> {113};
113 -> {114};
114 -> {115 117};
115 -> {116};
116 -> {117};
117 -> {118};
118 -> {119};
118 -> {119 121};
119 -> {120};
120 -> {121};
121 -> {122};
122 -> {123};
123 -> {124};
124 -> {126 125};
125 -> {132};
124 -> {125};
125 -> {126};
126 -> {127};
127 -> {128};
128 -> {129};
129 -> {130};
128 -> {130 129};
129 -> {137};
130 -> {131};
131 -> {132};
132 -> {133};
133 -> {134};
subgraph cluster_32 {
color=red
135 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_33 {
color=blue
136 [label="Enter block"];
137 [label="Access variable R|<local>/x|"];
138 [label="Type operator: (R|<local>/x| as? R|B|)"];
139 [label="Exit lhs of ?:"];
140 [label="Enter rhs of ?:"];
141 [label="Jump: ^test_3 Unit"];
142 [label="Stub" style="filled" fillcolor=gray];
143 [label="Lhs of ?: is not null"];
144 [label="Exit ?:"];
145 [label="Variable declaration: lval a: R|B|"];
146 [label="Access variable R|<local>/a|"];
147 [label="Function call: R|<local>/a|.R|/B.foo|()"];
148 [label="Access variable R|<local>/x|"];
149 [label="Function call: R|<local>/x|.R|/B.foo|()"];
150 [label="Exit block"];
}
151 [label="Exit function test_3" style="filled" fillcolor=red];
}
134 -> {135};
135 -> {136};
136 -> {137};
137 -> {138};
138 -> {139};
139 -> {143 140};
subgraph cluster_32 {
color=red
140 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_33 {
color=blue
141 [label="Enter block"];
142 [label="Access variable R|<local>/x|"];
143 [label="Type operator: (R|<local>/x| as? R|B|)"];
144 [label="Exit lhs of ?:"];
145 [label="Enter rhs of ?:"];
146 [label="Jump: ^test_3 Unit"];
147 [label="Stub" style="filled" fillcolor=gray];
148 [label="Lhs of ?: is not null"];
149 [label="Exit ?:"];
150 [label="Variable declaration: lval a: R|B|"];
151 [label="Access variable R|<local>/a|"];
152 [label="Function call: R|<local>/a|.R|/B.foo|()"];
153 [label="Access variable R|<local>/x|"];
154 [label="Smart cast: R|<local>/x|"];
155 [label="Function call: R|<local>/x|.R|/B.foo|()"];
156 [label="Exit block"];
}
157 [label="Exit function test_3" style="filled" fillcolor=red];
}
140 -> {141};
141 -> {151};
141 -> {142} [style=dotted];
142 -> {144} [style=dotted];
141 -> {142};
142 -> {143};
143 -> {144};
144 -> {145};
144 -> {148 145};
145 -> {146};
146 -> {147};
147 -> {148};
146 -> {157};
146 -> {147} [style=dotted];
147 -> {149} [style=dotted];
148 -> {149};
149 -> {150};
150 -> {151};
151 -> {152};
152 -> {153};
153 -> {154};
154 -> {155};
155 -> {156};
156 -> {157};
}
@@ -63,15 +63,16 @@ digraph safeCallAndEqualityToBool_kt {
color=blue
27 [label="Enter block"];
28 [label="Access variable R|<local>/s|"];
29 [label="Access variable R|kotlin/String.length|"];
30 [label="Exit block"];
29 [label="Smart cast: R|<local>/s|"];
30 [label="Access variable R|kotlin/String.length|"];
31 [label="Exit block"];
}
31 [label="Exit when branch result"];
32 [label="Exit when"];
32 [label="Exit when branch result"];
33 [label="Exit when"];
}
33 [label="Exit block"];
34 [label="Exit block"];
}
34 [label="Exit function test_1" style="filled" fillcolor=red];
35 [label="Exit function test_1" style="filled" fillcolor=red];
}
7 -> {8};
8 -> {9};
@@ -91,7 +92,7 @@ digraph safeCallAndEqualityToBool_kt {
22 -> {23};
23 -> {24};
24 -> {25};
25 -> {32};
25 -> {33};
26 -> {27};
27 -> {28};
28 -> {29};
@@ -100,76 +101,77 @@ digraph safeCallAndEqualityToBool_kt {
31 -> {32};
32 -> {33};
33 -> {34};
34 -> {35};
subgraph cluster_9 {
color=red
35 [label="Enter function test_2" style="filled" fillcolor=red];
36 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_10 {
color=blue
36 [label="Enter block"];
37 [label="Enter block"];
subgraph cluster_11 {
color=blue
37 [label="Enter when"];
38 [label="Enter when"];
subgraph cluster_12 {
color=blue
38 [label="Enter when branch condition "];
39 [label="Access variable R|<local>/s|"];
40 [label="Enter safe call"];
41 [label="Function call: $subj$.R|/check|()"];
42 [label="Exit safe call"];
43 [label="Const: Boolean(false)"];
44 [label="Equality operator =="];
45 [label="Exit when branch condition"];
39 [label="Enter when branch condition "];
40 [label="Access variable R|<local>/s|"];
41 [label="Enter safe call"];
42 [label="Function call: $subj$.R|/check|()"];
43 [label="Exit safe call"];
44 [label="Const: Boolean(false)"];
45 [label="Equality operator =="];
46 [label="Exit when branch condition"];
}
subgraph cluster_13 {
color=blue
46 [label="Enter when branch condition else"];
47 [label="Exit when branch condition"];
47 [label="Enter when branch condition else"];
48 [label="Exit when branch condition"];
}
48 [label="Enter when branch result"];
49 [label="Enter when branch result"];
subgraph cluster_14 {
color=blue
49 [label="Enter block"];
50 [label="Access variable R|<local>/s|"];
51 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
52 [label="Exit block"];
50 [label="Enter block"];
51 [label="Access variable R|<local>/s|"];
52 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
53 [label="Exit block"];
}
53 [label="Exit when branch result"];
54 [label="Enter when branch result"];
54 [label="Exit when branch result"];
55 [label="Enter when branch result"];
subgraph cluster_15 {
color=blue
55 [label="Enter block"];
56 [label="Access variable R|<local>/s|"];
57 [label="Access variable R|kotlin/String.length|"];
58 [label="Exit block"];
56 [label="Enter block"];
57 [label="Access variable R|<local>/s|"];
58 [label="Smart cast: R|<local>/s|"];
59 [label="Access variable R|kotlin/String.length|"];
60 [label="Exit block"];
}
59 [label="Exit when branch result"];
60 [label="Exit when"];
61 [label="Exit when branch result"];
62 [label="Exit when"];
}
61 [label="Exit block"];
63 [label="Exit block"];
}
62 [label="Exit function test_2" style="filled" fillcolor=red];
64 [label="Exit function test_2" style="filled" fillcolor=red];
}
35 -> {36};
36 -> {37};
37 -> {38};
38 -> {39};
39 -> {40 42};
40 -> {41};
39 -> {40};
40 -> {41 43};
41 -> {42};
42 -> {43};
43 -> {44};
44 -> {45};
45 -> {54 46};
46 -> {47};
45 -> {46};
46 -> {55 47};
47 -> {48};
48 -> {49};
49 -> {50};
50 -> {51};
51 -> {52};
52 -> {53};
53 -> {60};
54 -> {55};
53 -> {54};
54 -> {62};
55 -> {56};
56 -> {57};
57 -> {58};
@@ -177,159 +179,165 @@ digraph safeCallAndEqualityToBool_kt {
59 -> {60};
60 -> {61};
61 -> {62};
62 -> {63};
63 -> {64};
subgraph cluster_16 {
color=red
63 [label="Enter function test_3" style="filled" fillcolor=red];
65 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_17 {
color=blue
64 [label="Enter block"];
66 [label="Enter block"];
subgraph cluster_18 {
color=blue
65 [label="Enter when"];
67 [label="Enter when"];
subgraph cluster_19 {
color=blue
66 [label="Enter when branch condition "];
67 [label="Access variable R|<local>/s|"];
68 [label="Enter safe call"];
69 [label="Function call: $subj$.R|/check|()"];
70 [label="Exit safe call"];
71 [label="Const: Boolean(true)"];
72 [label="Equality operator !="];
73 [label="Exit when branch condition"];
68 [label="Enter when branch condition "];
69 [label="Access variable R|<local>/s|"];
70 [label="Enter safe call"];
71 [label="Function call: $subj$.R|/check|()"];
72 [label="Exit safe call"];
73 [label="Const: Boolean(true)"];
74 [label="Equality operator !="];
75 [label="Exit when branch condition"];
}
subgraph cluster_20 {
color=blue
74 [label="Enter when branch condition else"];
75 [label="Exit when branch condition"];
76 [label="Enter when branch condition else"];
77 [label="Exit when branch condition"];
}
76 [label="Enter when branch result"];
78 [label="Enter when branch result"];
subgraph cluster_21 {
color=blue
77 [label="Enter block"];
78 [label="Access variable R|<local>/s|"];
79 [label="Access variable R|kotlin/String.length|"];
80 [label="Exit block"];
79 [label="Enter block"];
80 [label="Access variable R|<local>/s|"];
81 [label="Smart cast: R|<local>/s|"];
82 [label="Access variable R|kotlin/String.length|"];
83 [label="Exit block"];
}
81 [label="Exit when branch result"];
82 [label="Enter when branch result"];
84 [label="Exit when branch result"];
85 [label="Enter when branch result"];
subgraph cluster_22 {
color=blue
83 [label="Enter block"];
84 [label="Access variable R|<local>/s|"];
85 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
86 [label="Exit block"];
86 [label="Enter block"];
87 [label="Access variable R|<local>/s|"];
88 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
89 [label="Exit block"];
}
87 [label="Exit when branch result"];
88 [label="Exit when"];
90 [label="Exit when branch result"];
91 [label="Exit when"];
}
89 [label="Exit block"];
92 [label="Exit block"];
}
90 [label="Exit function test_3" style="filled" fillcolor=red];
93 [label="Exit function test_3" style="filled" fillcolor=red];
}
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {67};
67 -> {68 70};
67 -> {68};
68 -> {69};
69 -> {70};
69 -> {70 72};
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {82 74};
73 -> {74};
74 -> {75};
75 -> {76};
75 -> {85 76};
76 -> {77};
77 -> {78};
78 -> {79};
79 -> {80};
80 -> {81};
81 -> {88};
81 -> {82};
82 -> {83};
83 -> {84};
84 -> {85};
84 -> {91};
85 -> {86};
86 -> {87};
87 -> {88};
88 -> {89};
89 -> {90};
90 -> {91};
91 -> {92};
92 -> {93};
subgraph cluster_23 {
color=red
91 [label="Enter function test_4" style="filled" fillcolor=red];
94 [label="Enter function test_4" style="filled" fillcolor=red];
subgraph cluster_24 {
color=blue
92 [label="Enter block"];
95 [label="Enter block"];
subgraph cluster_25 {
color=blue
93 [label="Enter when"];
96 [label="Enter when"];
subgraph cluster_26 {
color=blue
94 [label="Enter when branch condition "];
95 [label="Access variable R|<local>/s|"];
96 [label="Enter safe call"];
97 [label="Function call: $subj$.R|/check|()"];
98 [label="Exit safe call"];
99 [label="Const: Boolean(false)"];
100 [label="Equality operator !="];
101 [label="Exit when branch condition"];
97 [label="Enter when branch condition "];
98 [label="Access variable R|<local>/s|"];
99 [label="Enter safe call"];
100 [label="Function call: $subj$.R|/check|()"];
101 [label="Exit safe call"];
102 [label="Const: Boolean(false)"];
103 [label="Equality operator !="];
104 [label="Exit when branch condition"];
}
subgraph cluster_27 {
color=blue
102 [label="Enter when branch condition else"];
103 [label="Exit when branch condition"];
105 [label="Enter when branch condition else"];
106 [label="Exit when branch condition"];
}
104 [label="Enter when branch result"];
107 [label="Enter when branch result"];
subgraph cluster_28 {
color=blue
105 [label="Enter block"];
106 [label="Access variable R|<local>/s|"];
107 [label="Access variable R|kotlin/String.length|"];
108 [label="Exit block"];
108 [label="Enter block"];
109 [label="Access variable R|<local>/s|"];
110 [label="Smart cast: R|<local>/s|"];
111 [label="Access variable R|kotlin/String.length|"];
112 [label="Exit block"];
}
109 [label="Exit when branch result"];
110 [label="Enter when branch result"];
113 [label="Exit when branch result"];
114 [label="Enter when branch result"];
subgraph cluster_29 {
color=blue
111 [label="Enter block"];
112 [label="Access variable R|<local>/s|"];
113 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
114 [label="Exit block"];
115 [label="Enter block"];
116 [label="Access variable R|<local>/s|"];
117 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
118 [label="Exit block"];
}
115 [label="Exit when branch result"];
116 [label="Exit when"];
119 [label="Exit when branch result"];
120 [label="Exit when"];
}
117 [label="Exit block"];
121 [label="Exit block"];
}
118 [label="Exit function test_4" style="filled" fillcolor=red];
122 [label="Exit function test_4" style="filled" fillcolor=red];
}
91 -> {92};
92 -> {93};
93 -> {94};
94 -> {95};
95 -> {96 98};
95 -> {96};
96 -> {97};
97 -> {98};
98 -> {99};
98 -> {99 101};
99 -> {100};
100 -> {101};
101 -> {110 102};
101 -> {102};
102 -> {103};
103 -> {104};
104 -> {105};
104 -> {114 105};
105 -> {106};
106 -> {107};
107 -> {108};
108 -> {109};
109 -> {116};
109 -> {110};
110 -> {111};
111 -> {112};
112 -> {113};
113 -> {114};
113 -> {120};
114 -> {115};
115 -> {116};
116 -> {117};
117 -> {118};
118 -> {119};
119 -> {120};
120 -> {121};
121 -> {122};
}
@@ -47,20 +47,21 @@ digraph safeCalls_kt {
13 [label="Access variable R|<local>/x|"];
14 [label="Enter safe call"];
15 [label="Access variable R|<local>/x|"];
16 [label="Access variable R|kotlin/String.length|"];
17 [label="Const: Int(1)"];
18 [label="Equality operator =="];
19 [label="Function call: $subj$.R|/foo|(...)"];
20 [label="Exit safe call"];
21 [label="Access variable R|<local>/x|"];
22 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
23 [label="Exit block"];
16 [label="Smart cast: R|<local>/x|"];
17 [label="Access variable R|kotlin/String.length|"];
18 [label="Const: Int(1)"];
19 [label="Equality operator =="];
20 [label="Function call: $subj$.R|/foo|(...)"];
21 [label="Exit safe call"];
22 [label="Access variable R|<local>/x|"];
23 [label="Access variable <Inapplicable(UNSAFE_CALL): kotlin/String.length>#"];
24 [label="Exit block"];
}
24 [label="Exit function test" style="filled" fillcolor=red];
25 [label="Exit function test" style="filled" fillcolor=red];
}
11 -> {12};
12 -> {13};
13 -> {14 20};
13 -> {14 21};
14 -> {15};
15 -> {16};
16 -> {17};
@@ -71,239 +72,250 @@ digraph safeCalls_kt {
21 -> {22};
22 -> {23};
23 -> {24};
24 -> {25};
subgraph cluster_6 {
color=red
25 [label="Enter function bar" style="filled" fillcolor=red];
26 [label="Exit function bar" style="filled" fillcolor=red];
26 [label="Enter function bar" style="filled" fillcolor=red];
27 [label="Exit function bar" style="filled" fillcolor=red];
}
25 -> {26};
26 -> {27};
subgraph cluster_7 {
color=red
27 [label="Enter function bool" style="filled" fillcolor=red];
28 [label="Exit function bool" style="filled" fillcolor=red];
28 [label="Enter function bool" style="filled" fillcolor=red];
29 [label="Exit function bool" style="filled" fillcolor=red];
}
27 -> {28};
28 -> {29};
subgraph cluster_8 {
color=red
29 [label="Enter function id" style="filled" fillcolor=red];
30 [label="Exit function id" style="filled" fillcolor=red];
30 [label="Enter function id" style="filled" fillcolor=red];
31 [label="Exit function id" style="filled" fillcolor=red];
}
29 -> {30};
30 -> {31};
subgraph cluster_9 {
color=red
31 [label="Enter class A" style="filled" fillcolor=red];
32 [label="Exit class A" style="filled" fillcolor=red];
32 [label="Enter class A" style="filled" fillcolor=red];
33 [label="Exit class A" style="filled" fillcolor=red];
}
31 -> {32} [color=green];
32 -> {33} [color=green];
subgraph cluster_10 {
color=red
33 [label="Enter function test_2" style="filled" fillcolor=red];
34 [label="Enter function test_2" style="filled" fillcolor=red];
subgraph cluster_11 {
color=blue
34 [label="Enter block"];
35 [label="Access variable R|<local>/x|"];
36 [label="Type operator: (R|<local>/x| as? R|A|)"];
37 [label="Enter safe call"];
38 [label="Access variable R|<local>/x|"];
39 [label="Function call: $subj$.R|/A.bar|(...)"];
40 [label="Exit safe call"];
41 [label="Exit block"];
35 [label="Enter block"];
36 [label="Access variable R|<local>/x|"];
37 [label="Type operator: (R|<local>/x| as? R|A|)"];
38 [label="Enter safe call"];
39 [label="Access variable R|<local>/x|"];
40 [label="Smart cast: R|<local>/x|"];
41 [label="Function call: $subj$.R|/A.bar|(...)"];
42 [label="Exit safe call"];
43 [label="Exit block"];
}
42 [label="Exit function test_2" style="filled" fillcolor=red];
44 [label="Exit function test_2" style="filled" fillcolor=red];
}
33 -> {34};
34 -> {35};
35 -> {36};
36 -> {37 40};
37 -> {38};
36 -> {37};
37 -> {38 42};
38 -> {39};
39 -> {40};
40 -> {41};
41 -> {42};
42 -> {43};
43 -> {44};
subgraph cluster_12 {
color=red
43 [label="Enter function test_3" style="filled" fillcolor=red];
45 [label="Enter function test_3" style="filled" fillcolor=red];
subgraph cluster_13 {
color=blue
44 [label="Enter block"];
45 [label="Access variable R|<local>/x|"];
46 [label="Type operator: (R|<local>/x| as? R|A|)"];
47 [label="Enter safe call"];
48 [label="Access variable R|<local>/x|"];
49 [label="Function call: $subj$.R|/A.bar|(...)"];
50 [label="Exit safe call"];
51 [label="Enter safe call"];
52 [label="Access variable R|<local>/x|"];
53 [label="Function call: R|<local>/x|.R|/A.bool|()"];
54 [label="Function call: $subj$.R|/foo|(...)"];
55 [label="Exit safe call"];
56 [label="Enter safe call"];
57 [label="Postponed enter to lambda"];
46 [label="Enter block"];
47 [label="Access variable R|<local>/x|"];
48 [label="Type operator: (R|<local>/x| as? R|A|)"];
49 [label="Enter safe call"];
50 [label="Access variable R|<local>/x|"];
51 [label="Smart cast: R|<local>/x|"];
52 [label="Function call: $subj$.R|/A.bar|(...)"];
53 [label="Exit safe call"];
54 [label="Enter safe call"];
55 [label="Access variable R|<local>/x|"];
56 [label="Smart cast: R|<local>/x|"];
57 [label="Function call: R|<local>/x|.R|/A.bool|()"];
58 [label="Function call: $subj$.R|/foo|(...)"];
59 [label="Exit safe call"];
60 [label="Enter safe call"];
61 [label="Postponed enter to lambda"];
subgraph cluster_14 {
color=blue
65 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
69 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_15 {
color=blue
66 [label="Enter block"];
67 [label="Access variable R|<local>/x|"];
68 [label="Function call: R|<local>/x|.R|/A.bool|()"];
69 [label="Exit block"];
70 [label="Enter block"];
71 [label="Access variable R|<local>/x|"];
72 [label="Smart cast: R|<local>/x|"];
73 [label="Function call: R|<local>/x|.R|/A.bool|()"];
74 [label="Exit block"];
}
70 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
75 [label="Exit function anonymousFunction" style="filled" fillcolor=red];
}
58 [label="Postponed exit from lambda"];
59 [label="Function call: $subj$.R|/let|(...)"];
60 [label="Exit safe call"];
61 [label="Access variable R|<local>/x|"];
62 [label="Function call: R|<local>/x|.<Unresolved name: bool>#()"];
63 [label="Exit block"];
62 [label="Postponed exit from lambda"];
63 [label="Function call: $subj$.R|/let|(...)"];
64 [label="Exit safe call"];
65 [label="Access variable R|<local>/x|"];
66 [label="Function call: R|<local>/x|.<Unresolved name: bool>#()"];
67 [label="Exit block"];
}
64 [label="Exit function test_3" style="filled" fillcolor=red];
68 [label="Exit function test_3" style="filled" fillcolor=red];
}
43 -> {44};
44 -> {45};
45 -> {46};
46 -> {47 50};
46 -> {47};
47 -> {48};
48 -> {49};
48 -> {49 53};
49 -> {50};
50 -> {51 55};
50 -> {51};
51 -> {52};
52 -> {53};
53 -> {54};
53 -> {54 59};
54 -> {55};
55 -> {56 60};
55 -> {56};
56 -> {57};
57 -> {58 65};
57 -> {65} [style=dashed];
57 -> {58};
58 -> {59};
59 -> {60};
59 -> {60 64};
60 -> {61};
61 -> {62};
61 -> {62 69};
61 -> {69} [style=dashed];
62 -> {63};
63 -> {64};
64 -> {65};
65 -> {66};
66 -> {67};
67 -> {68};
68 -> {69};
69 -> {70};
70 -> {71};
71 -> {72};
72 -> {73};
73 -> {74};
74 -> {75};
subgraph cluster_16 {
color=red
71 [label="Enter function test_4" style="filled" fillcolor=red];
76 [label="Enter function test_4" style="filled" fillcolor=red];
subgraph cluster_17 {
color=blue
72 [label="Enter block"];
73 [label="Access variable R|<local>/x|"];
74 [label="Enter safe call"];
75 [label="Function call: $subj$.R|/A.id|()"];
76 [label="Exit safe call"];
77 [label="Enter safe call"];
78 [label="Function call: $subj$.R|/A.bool|()"];
79 [label="Exit safe call"];
80 [label="Access variable R|<local>/x|"];
81 [label="Function call: R|<local>/x|.<Inapplicable(UNSAFE_CALL): /A.id>#()"];
82 [label="Exit block"];
77 [label="Enter block"];
78 [label="Access variable R|<local>/x|"];
79 [label="Enter safe call"];
80 [label="Function call: $subj$.R|/A.id|()"];
81 [label="Exit safe call"];
82 [label="Enter safe call"];
83 [label="Function call: $subj$.R|/A.bool|()"];
84 [label="Exit safe call"];
85 [label="Access variable R|<local>/x|"];
86 [label="Function call: R|<local>/x|.<Inapplicable(UNSAFE_CALL): /A.id>#()"];
87 [label="Exit block"];
}
83 [label="Exit function test_4" style="filled" fillcolor=red];
88 [label="Exit function test_4" style="filled" fillcolor=red];
}
71 -> {72};
72 -> {73};
73 -> {74 76};
74 -> {75};
75 -> {76};
76 -> {77 79};
76 -> {77};
77 -> {78};
78 -> {79};
78 -> {79 81};
79 -> {80};
80 -> {81};
81 -> {82};
81 -> {82 84};
82 -> {83};
subgraph cluster_18 {
color=red
84 [label="Enter function boo" style="filled" fillcolor=red];
subgraph cluster_19 {
color=blue
85 [label="Enter block"];
86 [label="Exit block"];
}
87 [label="Exit function boo" style="filled" fillcolor=red];
}
83 -> {84};
84 -> {85};
85 -> {86};
86 -> {87};
87 -> {88};
subgraph cluster_18 {
color=red
89 [label="Enter function boo" style="filled" fillcolor=red];
subgraph cluster_19 {
color=blue
90 [label="Enter block"];
91 [label="Exit block"];
}
92 [label="Exit function boo" style="filled" fillcolor=red];
}
89 -> {90};
90 -> {91};
91 -> {92};
subgraph cluster_20 {
color=red
88 [label="Enter function test_5" style="filled" fillcolor=red];
93 [label="Enter function test_5" style="filled" fillcolor=red];
subgraph cluster_21 {
color=blue
89 [label="Enter block"];
90 [label="Access variable R|<local>/x|"];
91 [label="Enter safe call"];
92 [label="Postponed enter to lambda"];
94 [label="Enter block"];
95 [label="Access variable R|<local>/x|"];
96 [label="Enter safe call"];
97 [label="Postponed enter to lambda"];
subgraph cluster_22 {
color=blue
107 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
113 [label="Enter function anonymousFunction" style="filled" fillcolor=red];
subgraph cluster_23 {
color=blue
108 [label="Enter block"];
109 [label="Jump: ^test_5 Unit"];
110 [label="Stub" style="filled" fillcolor=gray];
111 [label="Exit block" style="filled" fillcolor=gray];
114 [label="Enter block"];
115 [label="Jump: ^test_5 Unit"];
116 [label="Stub" style="filled" fillcolor=gray];
117 [label="Exit block" style="filled" fillcolor=gray];
}
112 [label="Exit function anonymousFunction" style="filled" fillcolor=red style="filled" fillcolor=gray];
118 [label="Exit function anonymousFunction" style="filled" fillcolor=red style="filled" fillcolor=gray];
}
93 [label="Call arguments union" style="filled" fillcolor=gray];
94 [label="Postponed exit from lambda" style="filled" fillcolor=gray];
95 [label="Function call: $subj$.R|kotlin/let|<R|A|, R|kotlin/Nothing|>(...)" style="filled" fillcolor=gray];
96 [label="Stub" style="filled" fillcolor=gray];
97 [label="Exit safe call"];
98 [label="Enter safe call"];
99 [label="Access variable R|<local>/x|"];
100 [label="Function call: R|<local>/x|.R|/A.bool|()"];
101 [label="Function call: $subj$.R|/boo|(...)"];
98 [label="Call arguments union" style="filled" fillcolor=gray];
99 [label="Postponed exit from lambda" style="filled" fillcolor=gray];
100 [label="Function call: $subj$.R|kotlin/let|<R|A|, R|kotlin/Nothing|>(...)" style="filled" fillcolor=gray];
101 [label="Stub" style="filled" fillcolor=gray];
102 [label="Exit safe call"];
103 [label="Access variable R|<local>/x|"];
104 [label="Function call: R|<local>/x|.<Inapplicable(UNSAFE_CALL): /A.id>#()"];
105 [label="Exit block"];
103 [label="Enter safe call"];
104 [label="Access variable R|<local>/x|"];
105 [label="Smart cast: R|<local>/x|"];
106 [label="Function call: R|<local>/x|.R|/A.bool|()"];
107 [label="Function call: $subj$.R|/boo|(...)"];
108 [label="Exit safe call"];
109 [label="Access variable R|<local>/x|"];
110 [label="Function call: R|<local>/x|.<Inapplicable(UNSAFE_CALL): /A.id>#()"];
111 [label="Exit block"];
}
106 [label="Exit function test_5" style="filled" fillcolor=red];
112 [label="Exit function test_5" style="filled" fillcolor=red];
}
88 -> {89};
89 -> {90};
90 -> {91 97};
91 -> {92};
92 -> {107};
92 -> {94} [color=red];
92 -> {107} [style=dashed];
93 -> {95} [style=dotted];
94 -> {95} [style=dotted];
95 -> {96} [style=dotted];
95 -> {106} [style=dotted] [label=onUncaughtException];
96 -> {97} [style=dotted];
97 -> {98 102};
98 -> {99};
99 -> {100};
100 -> {101};
101 -> {102};
102 -> {103};
93 -> {94};
94 -> {95};
95 -> {96 102};
96 -> {97};
97 -> {113};
97 -> {99} [color=red];
97 -> {113} [style=dashed];
98 -> {100} [style=dotted];
99 -> {100} [style=dotted];
100 -> {101} [style=dotted];
100 -> {112} [style=dotted] [label=onUncaughtException];
101 -> {102} [style=dotted];
102 -> {103 108};
103 -> {104};
104 -> {105};
105 -> {106};
106 -> {107};
107 -> {108};
108 -> {109};
109 -> {106};
109 -> {110} [style=dotted];
110 -> {111} [style=dotted];
111 -> {112} [style=dotted];
112 -> {94 93} [style=dotted];
109 -> {110};
110 -> {111};
111 -> {112};
113 -> {114};
114 -> {115};
115 -> {112};
115 -> {116} [style=dotted];
116 -> {117} [style=dotted];
117 -> {118} [style=dotted];
118 -> {99 98} [style=dotted];
}
@@ -0,0 +1,38 @@
FILE: unstableSmartCastOnSafeCallArgument.kt
public abstract class Foo : R|kotlin/Any| {
public constructor(): R|Foo| {
super<R|kotlin/Any|>()
}
public abstract val bar: R|Bar?|
public get(): R|Bar?|
}
public abstract class Bar : R|kotlin/Any| {
public constructor(): R|Bar| {
super<R|kotlin/Any|>()
}
public abstract val buz: R|Buz?|
public get(): R|Buz?|
}
public final class Buz : R|kotlin/Any| {
public constructor(): R|Buz| {
super<R|kotlin/Any|>()
}
}
public final fun takesNullable(b: R|Buz?|): R|kotlin/Unit| {
}
public final fun takesNonNull(b: R|Buz|): R|kotlin/Unit| {
}
public final fun foo(foo: R|Foo|): R|kotlin/Unit| {
when () {
!=(R|<local>/foo|.R|/Foo.bar|?.{ $subj$.R|/Bar.buz| }, Null(null)) -> {
R|/takesNullable|(R|<local>/foo|.R|/Foo.bar|?.{ $subj$.R|/Bar.buz| })
<Inapplicable(INAPPLICABLE): /takesNonNull>#(R|<local>/foo|.R|/Foo.bar|?.{ $subj$.R|/Bar.buz| })
}
}
}
@@ -0,0 +1,21 @@
abstract class Foo {
abstract val bar: Bar?
}
abstract class Bar {
abstract val buz: Buz?
}
class Buz
fun takesNullable(b: Buz?) {}
fun takesNonNull(b: Buz) {}
fun foo(foo: Foo) {
if (foo.bar?.buz != null) {
// Here we have unstable smart-cast on foo.bar?.buz
takesNullable(foo.bar?.buz) // OK
takesNonNull(<!ARGUMENT_TYPE_MISMATCH!>foo.bar?.buz<!>) // NOT OK
}
}