OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library least_upper_bound_test; | 5 library least_upper_bound_test; |
6 | 6 |
7 import 'package:expect/expect.dart'; | 7 import 'package:expect/expect.dart'; |
8 import 'package:async_helper/async_helper.dart'; | 8 import 'package:async_helper/async_helper.dart'; |
9 import 'package:compiler/src/dart_types.dart'; | 9 import 'package:compiler/src/dart_types.dart'; |
10 import 'package:compiler/src/elements/elements.dart' | 10 import 'package:compiler/src/elements/elements.dart' show Element, ClassElement; |
11 show Element, ClassElement; | |
12 | 11 |
13 import 'type_test_helper.dart'; | 12 import 'type_test_helper.dart'; |
14 | 13 |
15 void main() { | 14 void main() { |
16 testInterface1(); | 15 testInterface1(); |
17 testInterface2(); | 16 testInterface2(); |
18 testGeneric(); | 17 testGeneric(); |
19 testMixin(); | 18 testMixin(); |
20 testFunction(); | 19 testFunction(); |
21 testTypeVariable(); | 20 testTypeVariable(); |
22 } | 21 } |
23 | 22 |
24 void testInterface1() { | 23 void testInterface1() { |
25 asyncTest(() => TypeEnvironment.create(r""" | 24 asyncTest(() => TypeEnvironment.create(r""" |
26 class A {} // A and B have equal depth. | 25 class A {} // A and B have equal depth. |
27 class B {} | 26 class B {} |
28 class I implements A, B {} | 27 class I implements A, B {} |
29 class J implements A, B {} | 28 class J implements A, B {} |
30 """).then((env) { | 29 """).then((env) { |
| 30 DartType Object_ = env['Object']; |
| 31 DartType A = env['A']; |
| 32 DartType B = env['B']; |
| 33 DartType I = env['I']; |
| 34 DartType J = env['J']; |
31 | 35 |
32 DartType Object_ = env['Object']; | 36 checkLub(DartType a, DartType b, DartType expect) { |
33 DartType A = env['A']; | 37 DartType lub = env.computeLeastUpperBound(a, b); |
34 DartType B = env['B']; | 38 Expect.equals( |
35 DartType I = env['I']; | 39 expect, lub, 'Unexpected lub($a,$b) = $lub, expected $expect.'); |
36 DartType J = env['J']; | 40 } |
37 | 41 |
38 checkLub(DartType a, DartType b, DartType expect) { | 42 checkLub(Object_, Object_, Object_); |
39 DartType lub = env.computeLeastUpperBound(a, b); | 43 checkLub(Object_, A, Object_); |
40 Expect.equals(expect, lub, | 44 checkLub(Object_, B, Object_); |
41 'Unexpected lub($a,$b) = $lub, expected $expect.'); | 45 checkLub(Object_, I, Object_); |
42 } | 46 checkLub(Object_, J, Object_); |
43 | 47 |
44 checkLub(Object_, Object_, Object_); | 48 checkLub(A, Object_, Object_); |
45 checkLub(Object_, A, Object_); | 49 checkLub(A, A, A); |
46 checkLub(Object_, B, Object_); | 50 checkLub(A, B, Object_); |
47 checkLub(Object_, I, Object_); | 51 checkLub(A, I, A); |
48 checkLub(Object_, J, Object_); | 52 checkLub(A, J, A); |
49 | 53 |
50 checkLub(A, Object_, Object_); | 54 checkLub(B, Object_, Object_); |
51 checkLub(A, A, A); | 55 checkLub(B, A, Object_); |
52 checkLub(A, B, Object_); | 56 checkLub(B, B, B); |
53 checkLub(A, I, A); | 57 checkLub(B, I, B); |
54 checkLub(A, J, A); | 58 checkLub(B, J, B); |
55 | 59 |
56 checkLub(B, Object_, Object_); | 60 checkLub(I, Object_, Object_); |
57 checkLub(B, A, Object_); | 61 checkLub(I, A, A); |
58 checkLub(B, B, B); | 62 checkLub(I, B, B); |
59 checkLub(B, I, B); | 63 checkLub(I, I, I); |
60 checkLub(B, J, B); | 64 checkLub(I, J, Object_); |
61 | 65 |
62 checkLub(I, Object_, Object_); | 66 checkLub(J, Object_, Object_); |
63 checkLub(I, A, A); | 67 checkLub(J, A, A); |
64 checkLub(I, B, B); | 68 checkLub(J, B, B); |
65 checkLub(I, I, I); | 69 checkLub(J, I, Object_); |
66 checkLub(I, J, Object_); | 70 checkLub(J, J, J); |
67 | 71 })); |
68 checkLub(J, Object_, Object_); | |
69 checkLub(J, A, A); | |
70 checkLub(J, B, B); | |
71 checkLub(J, I, Object_); | |
72 checkLub(J, J, J); | |
73 })); | |
74 } | 72 } |
75 | 73 |
76 void testInterface2() { | 74 void testInterface2() { |
77 asyncTest(() => TypeEnvironment.create(r""" | 75 asyncTest(() => TypeEnvironment.create(r""" |
78 class A {} | 76 class A {} |
79 class B {} | 77 class B {} |
80 class C extends B {} // This makes C have higher depth than A. | 78 class C extends B {} // This makes C have higher depth than A. |
81 class I implements A, C {} | 79 class I implements A, C {} |
82 class J implements A, C {} | 80 class J implements A, C {} |
83 """).then((env) { | 81 """).then((env) { |
| 82 DartType Object_ = env['Object']; |
| 83 DartType A = env['A']; |
| 84 DartType B = env['B']; |
| 85 DartType C = env['C']; |
| 86 DartType I = env['I']; |
| 87 DartType J = env['J']; |
84 | 88 |
85 DartType Object_ = env['Object']; | 89 checkLub(DartType a, DartType b, DartType expectedLub) { |
86 DartType A = env['A']; | 90 DartType lub = env.computeLeastUpperBound(a, b); |
87 DartType B = env['B']; | 91 Expect.equals(expectedLub, lub, |
88 DartType C = env['C']; | 92 'Unexpected lub($a,$b) = $lub, expected $expectedLub'); |
89 DartType I = env['I']; | 93 } |
90 DartType J = env['J']; | |
91 | 94 |
92 checkLub(DartType a, DartType b, DartType expectedLub) { | 95 checkLub(Object_, Object_, Object_); |
93 DartType lub = env.computeLeastUpperBound(a, b); | 96 checkLub(Object_, A, Object_); |
94 Expect.equals(expectedLub, lub, | 97 checkLub(Object_, B, Object_); |
95 'Unexpected lub($a,$b) = $lub, expected $expectedLub'); | 98 checkLub(Object_, C, Object_); |
96 } | 99 checkLub(Object_, I, Object_); |
| 100 checkLub(Object_, J, Object_); |
97 | 101 |
98 checkLub(Object_, Object_, Object_); | 102 checkLub(A, Object_, Object_); |
99 checkLub(Object_, A, Object_); | 103 checkLub(A, A, A); |
100 checkLub(Object_, B, Object_); | 104 checkLub(A, B, Object_); |
101 checkLub(Object_, C, Object_); | 105 checkLub(A, C, Object_); |
102 checkLub(Object_, I, Object_); | 106 checkLub(A, I, A); |
103 checkLub(Object_, J, Object_); | 107 checkLub(A, J, A); |
104 | 108 |
105 checkLub(A, Object_, Object_); | 109 checkLub(B, Object_, Object_); |
106 checkLub(A, A, A); | 110 checkLub(B, A, Object_); |
107 checkLub(A, B, Object_); | 111 checkLub(B, B, B); |
108 checkLub(A, C, Object_); | 112 checkLub(B, C, B); |
109 checkLub(A, I, A); | 113 checkLub(B, I, B); |
110 checkLub(A, J, A); | 114 checkLub(B, J, B); |
111 | 115 |
112 checkLub(B, Object_, Object_); | 116 checkLub(C, Object_, Object_); |
113 checkLub(B, A, Object_); | 117 checkLub(C, A, Object_); |
114 checkLub(B, B, B); | 118 checkLub(C, B, B); |
115 checkLub(B, C, B); | 119 checkLub(C, C, C); |
116 checkLub(B, I, B); | 120 checkLub(C, I, C); |
117 checkLub(B, J, B); | 121 checkLub(C, J, C); |
118 | 122 |
119 checkLub(C, Object_, Object_); | 123 checkLub(I, Object_, Object_); |
120 checkLub(C, A, Object_); | 124 checkLub(I, A, A); |
121 checkLub(C, B, B); | 125 checkLub(I, B, B); |
122 checkLub(C, C, C); | 126 checkLub(I, C, C); |
123 checkLub(C, I, C); | 127 checkLub(I, I, I); |
124 checkLub(C, J, C); | 128 checkLub(I, J, C); |
125 | 129 |
126 checkLub(I, Object_, Object_); | 130 checkLub(J, Object_, Object_); |
127 checkLub(I, A, A); | 131 checkLub(J, A, A); |
128 checkLub(I, B, B); | 132 checkLub(J, B, B); |
129 checkLub(I, C, C); | 133 checkLub(J, C, C); |
130 checkLub(I, I, I); | 134 checkLub(J, I, C); |
131 checkLub(I, J, C); | 135 checkLub(J, J, J); |
132 | 136 })); |
133 checkLub(J, Object_, Object_); | |
134 checkLub(J, A, A); | |
135 checkLub(J, B, B); | |
136 checkLub(J, C, C); | |
137 checkLub(J, I, C); | |
138 checkLub(J, J, J); | |
139 })); | |
140 } | 137 } |
141 | 138 |
142 void testGeneric() { | 139 void testGeneric() { |
143 asyncTest(() => TypeEnvironment.create(r""" | 140 asyncTest(() => TypeEnvironment.create(r""" |
144 class A {} | 141 class A {} |
145 class B {} | 142 class B {} |
146 class C extends B {} | 143 class C extends B {} |
147 class I<T> {} | 144 class I<T> {} |
148 """).then((env) { | 145 """).then((env) { |
| 146 DartType Object_ = env['Object']; |
| 147 DartType A = env['A']; |
| 148 DartType B = env['B']; |
| 149 DartType C = env['C']; |
| 150 ClassElement I = env.getElement('I'); |
| 151 DartType I_A = instantiate(I, [A]); |
| 152 DartType I_B = instantiate(I, [B]); |
| 153 DartType I_C = instantiate(I, [C]); |
149 | 154 |
150 DartType Object_ = env['Object']; | 155 checkLub(DartType a, DartType b, DartType expectedLub) { |
151 DartType A = env['A']; | 156 DartType lub = env.computeLeastUpperBound(a, b); |
152 DartType B = env['B']; | 157 Expect.equals(expectedLub, lub, |
153 DartType C = env['C']; | 158 'Unexpected lub($a,$b) = $lub, expected $expectedLub'); |
154 ClassElement I = env.getElement('I'); | 159 } |
155 DartType I_A = instantiate(I, [A]); | |
156 DartType I_B = instantiate(I, [B]); | |
157 DartType I_C = instantiate(I, [C]); | |
158 | 160 |
159 checkLub(DartType a, DartType b, DartType expectedLub) { | 161 checkLub(Object_, Object_, Object_); |
160 DartType lub = env.computeLeastUpperBound(a, b); | 162 checkLub(Object_, A, Object_); |
161 Expect.equals(expectedLub, lub, | 163 checkLub(Object_, B, Object_); |
162 'Unexpected lub($a,$b) = $lub, expected $expectedLub'); | 164 checkLub(Object_, C, Object_); |
163 } | 165 checkLub(Object_, I_A, Object_); |
| 166 checkLub(Object_, I_B, Object_); |
| 167 checkLub(Object_, I_C, Object_); |
164 | 168 |
165 checkLub(Object_, Object_, Object_); | 169 checkLub(A, Object_, Object_); |
166 checkLub(Object_, A, Object_); | 170 checkLub(A, A, A); |
167 checkLub(Object_, B, Object_); | 171 checkLub(A, B, Object_); |
168 checkLub(Object_, C, Object_); | 172 checkLub(A, C, Object_); |
169 checkLub(Object_, I_A, Object_); | 173 checkLub(A, I_A, Object_); |
170 checkLub(Object_, I_B, Object_); | 174 checkLub(A, I_B, Object_); |
171 checkLub(Object_, I_C, Object_); | 175 checkLub(A, I_C, Object_); |
172 | 176 |
173 checkLub(A, Object_, Object_); | 177 checkLub(B, Object_, Object_); |
174 checkLub(A, A, A); | 178 checkLub(B, A, Object_); |
175 checkLub(A, B, Object_); | 179 checkLub(B, B, B); |
176 checkLub(A, C, Object_); | 180 checkLub(B, C, B); |
177 checkLub(A, I_A, Object_); | 181 checkLub(B, I_A, Object_); |
178 checkLub(A, I_B, Object_); | 182 checkLub(B, I_B, Object_); |
179 checkLub(A, I_C, Object_); | 183 checkLub(B, I_C, Object_); |
180 | 184 |
181 checkLub(B, Object_, Object_); | 185 checkLub(C, Object_, Object_); |
182 checkLub(B, A, Object_); | 186 checkLub(C, A, Object_); |
183 checkLub(B, B, B); | 187 checkLub(C, B, B); |
184 checkLub(B, C, B); | 188 checkLub(C, C, C); |
185 checkLub(B, I_A, Object_); | 189 checkLub(C, I_A, Object_); |
186 checkLub(B, I_B, Object_); | 190 checkLub(C, I_B, Object_); |
187 checkLub(B, I_C, Object_); | 191 checkLub(C, I_C, Object_); |
188 | 192 |
189 checkLub(C, Object_, Object_); | 193 checkLub(I_A, Object_, Object_); |
190 checkLub(C, A, Object_); | 194 checkLub(I_A, A, Object_); |
191 checkLub(C, B, B); | 195 checkLub(I_A, B, Object_); |
192 checkLub(C, C, C); | 196 checkLub(I_A, C, Object_); |
193 checkLub(C, I_A, Object_); | 197 checkLub(I_A, I_A, I_A); |
194 checkLub(C, I_B, Object_); | 198 checkLub(I_A, I_B, Object_); |
195 checkLub(C, I_C, Object_); | 199 checkLub(I_A, I_C, Object_); |
196 | 200 |
197 checkLub(I_A, Object_, Object_); | 201 checkLub(I_B, Object_, Object_); |
198 checkLub(I_A, A, Object_); | 202 checkLub(I_B, A, Object_); |
199 checkLub(I_A, B, Object_); | 203 checkLub(I_B, B, Object_); |
200 checkLub(I_A, C, Object_); | 204 checkLub(I_B, C, Object_); |
201 checkLub(I_A, I_A, I_A); | 205 checkLub(I_B, I_A, Object_); |
202 checkLub(I_A, I_B, Object_); | 206 checkLub(I_B, I_B, I_B); |
203 checkLub(I_A, I_C, Object_); | 207 checkLub(I_B, I_C, Object_); |
204 | 208 |
205 checkLub(I_B, Object_, Object_); | 209 checkLub(I_C, Object_, Object_); |
206 checkLub(I_B, A, Object_); | 210 checkLub(I_C, A, Object_); |
207 checkLub(I_B, B, Object_); | 211 checkLub(I_C, B, Object_); |
208 checkLub(I_B, C, Object_); | 212 checkLub(I_C, C, Object_); |
209 checkLub(I_B, I_A, Object_); | 213 checkLub(I_C, I_A, Object_); |
210 checkLub(I_B, I_B, I_B); | 214 checkLub(I_C, I_B, Object_); |
211 checkLub(I_B, I_C, Object_); | 215 checkLub(I_C, I_C, I_C); |
212 | 216 })); |
213 checkLub(I_C, Object_, Object_); | |
214 checkLub(I_C, A, Object_); | |
215 checkLub(I_C, B, Object_); | |
216 checkLub(I_C, C, Object_); | |
217 checkLub(I_C, I_A, Object_); | |
218 checkLub(I_C, I_B, Object_); | |
219 checkLub(I_C, I_C, I_C); | |
220 })); | |
221 } | 217 } |
222 | 218 |
223 void testMixin() { | 219 void testMixin() { |
224 asyncTest(() => TypeEnvironment.create(r""" | 220 asyncTest(() => TypeEnvironment.create(r""" |
225 class A {} | 221 class A {} |
226 class B {} | 222 class B {} |
227 class C extends B {} | 223 class C extends B {} |
228 class D extends C {} // This makes D have higher depth than Object+A. | 224 class D extends C {} // This makes D have higher depth than Object+A. |
229 class I extends Object with A, B implements A, D {} | 225 class I extends Object with A, B implements A, D {} |
230 class I2 extends Object with A, B implements A, D {} | 226 class I2 extends Object with A, B implements A, D {} |
231 class J extends Object with B, A implements A, D {} | 227 class J extends Object with B, A implements A, D {} |
232 """).then((env) { | 228 """).then((env) { |
| 229 DartType Object_ = env['Object']; |
| 230 DartType A = env['A']; |
| 231 DartType B = env['B']; |
| 232 DartType C = env['C']; |
| 233 DartType D = env['D']; |
| 234 DartType I = env['I']; |
| 235 DartType I2 = env['I2']; |
| 236 DartType J = env['J']; |
233 | 237 |
234 DartType Object_ = env['Object']; | 238 checkLub(DartType a, DartType b, DartType expectedLub) { |
235 DartType A = env['A']; | 239 DartType lub = env.computeLeastUpperBound(a, b); |
236 DartType B = env['B']; | 240 Expect.equals(expectedLub, lub, |
237 DartType C = env['C']; | 241 'Unexpected lub($a,$b) = $lub, expected $expectedLub'); |
238 DartType D = env['D']; | 242 } |
239 DartType I = env['I']; | |
240 DartType I2 = env['I2']; | |
241 DartType J = env['J']; | |
242 | 243 |
243 checkLub(DartType a, DartType b, DartType expectedLub) { | 244 checkLub(Object_, Object_, Object_); |
244 DartType lub = env.computeLeastUpperBound(a, b); | 245 checkLub(Object_, A, Object_); |
245 Expect.equals(expectedLub, lub, | 246 checkLub(Object_, B, Object_); |
246 'Unexpected lub($a,$b) = $lub, expected $expectedLub'); | 247 checkLub(Object_, C, Object_); |
247 } | 248 checkLub(Object_, D, Object_); |
| 249 checkLub(Object_, I, Object_); |
| 250 checkLub(Object_, I2, Object_); |
| 251 checkLub(Object_, J, Object_); |
248 | 252 |
249 checkLub(Object_, Object_, Object_); | 253 checkLub(A, Object_, Object_); |
250 checkLub(Object_, A, Object_); | 254 checkLub(A, A, A); |
251 checkLub(Object_, B, Object_); | 255 checkLub(A, B, Object_); |
252 checkLub(Object_, C, Object_); | 256 checkLub(A, C, Object_); |
253 checkLub(Object_, D, Object_); | 257 checkLub(A, D, Object_); |
254 checkLub(Object_, I, Object_); | 258 checkLub(A, I, A); |
255 checkLub(Object_, I2, Object_); | 259 checkLub(A, I2, A); |
256 checkLub(Object_, J, Object_); | 260 checkLub(A, J, A); |
257 | 261 |
258 checkLub(A, Object_, Object_); | 262 checkLub(B, Object_, Object_); |
259 checkLub(A, A, A); | 263 checkLub(B, A, Object_); |
260 checkLub(A, B, Object_); | 264 checkLub(B, B, B); |
261 checkLub(A, C, Object_); | 265 checkLub(B, C, B); |
262 checkLub(A, D, Object_); | 266 checkLub(B, D, B); |
263 checkLub(A, I, A); | 267 checkLub(B, I, B); |
264 checkLub(A, I2, A); | 268 checkLub(B, I2, B); |
265 checkLub(A, J, A); | 269 checkLub(B, J, B); |
266 | 270 |
267 checkLub(B, Object_, Object_); | 271 checkLub(C, Object_, Object_); |
268 checkLub(B, A, Object_); | 272 checkLub(C, A, Object_); |
269 checkLub(B, B, B); | 273 checkLub(C, B, B); |
270 checkLub(B, C, B); | 274 checkLub(C, C, C); |
271 checkLub(B, D, B); | 275 checkLub(C, D, C); |
272 checkLub(B, I, B); | 276 checkLub(C, I, C); |
273 checkLub(B, I2, B); | 277 checkLub(C, I2, C); |
274 checkLub(B, J, B); | 278 checkLub(C, J, C); |
275 | 279 |
276 checkLub(C, Object_, Object_); | 280 checkLub(D, Object_, Object_); |
277 checkLub(C, A, Object_); | 281 checkLub(D, A, Object_); |
278 checkLub(C, B, B); | 282 checkLub(D, B, B); |
279 checkLub(C, C, C); | 283 checkLub(D, C, C); |
280 checkLub(C, D, C); | 284 checkLub(D, D, D); |
281 checkLub(C, I, C); | 285 checkLub(D, I, D); |
282 checkLub(C, I2, C); | 286 checkLub(D, I2, D); |
283 checkLub(C, J, C); | 287 checkLub(D, J, D); |
284 | 288 |
285 checkLub(D, Object_, Object_); | 289 checkLub(I, Object_, Object_); |
286 checkLub(D, A, Object_); | 290 checkLub(I, A, A); |
287 checkLub(D, B, B); | 291 checkLub(I, B, B); |
288 checkLub(D, C, C); | 292 checkLub(I, C, C); |
289 checkLub(D, D, D); | 293 checkLub(I, D, D); |
290 checkLub(D, I, D); | 294 checkLub(I, I, I); |
291 checkLub(D, I2, D); | 295 checkLub(I, I2, D); |
292 checkLub(D, J, D); | 296 checkLub(I, J, D); |
293 | 297 |
294 checkLub(I, Object_, Object_); | 298 checkLub(I2, Object_, Object_); |
295 checkLub(I, A, A); | 299 checkLub(I2, A, A); |
296 checkLub(I, B, B); | 300 checkLub(I2, B, B); |
297 checkLub(I, C, C); | 301 checkLub(I2, C, C); |
298 checkLub(I, D, D); | 302 checkLub(I2, D, D); |
299 checkLub(I, I, I); | 303 checkLub(I2, I, D); |
300 checkLub(I, I2, D); | 304 checkLub(I2, I2, I2); |
301 checkLub(I, J, D); | 305 checkLub(I2, J, D); |
302 | 306 |
303 checkLub(I2, Object_, Object_); | 307 checkLub(J, Object_, Object_); |
304 checkLub(I2, A, A); | 308 checkLub(J, A, A); |
305 checkLub(I2, B, B); | 309 checkLub(J, B, B); |
306 checkLub(I2, C, C); | 310 checkLub(J, C, C); |
307 checkLub(I2, D, D); | 311 checkLub(J, D, D); |
308 checkLub(I2, I, D); | 312 checkLub(J, I, D); |
309 checkLub(I2, I2, I2); | 313 checkLub(J, I2, D); |
310 checkLub(I2, J, D); | 314 checkLub(J, J, J); |
311 | 315 })); |
312 checkLub(J, Object_, Object_); | |
313 checkLub(J, A, A); | |
314 checkLub(J, B, B); | |
315 checkLub(J, C, C); | |
316 checkLub(J, D, D); | |
317 checkLub(J, I, D); | |
318 checkLub(J, I2, D); | |
319 checkLub(J, J, J); | |
320 })); | |
321 } | 316 } |
322 | 317 |
323 void testFunction() { | 318 void testFunction() { |
324 asyncTest(() => TypeEnvironment.create(r""" | 319 asyncTest(() => TypeEnvironment.create(r""" |
325 class A {} | 320 class A {} |
326 class B {} | 321 class B {} |
327 class C extends B {} | 322 class C extends B {} |
328 | 323 |
329 typedef dynamic__(); | 324 typedef dynamic__(); |
330 typedef void void__(); | 325 typedef void void__(); |
331 typedef A A__(); | 326 typedef A A__(); |
332 typedef B B__(); | 327 typedef B B__(); |
333 typedef C C__(); | 328 typedef C C__(); |
334 | 329 |
335 typedef void void__A_B(A a, B b); | 330 typedef void void__A_B(A a, B b); |
336 typedef void void__A_C(A a, C b); | 331 typedef void void__A_C(A a, C b); |
337 typedef void void__B_A(B a, A b); | 332 typedef void void__B_A(B a, A b); |
338 typedef void void__B_C(B a, C b); | 333 typedef void void__B_C(B a, C b); |
339 | 334 |
340 typedef void void___B([B a]); | 335 typedef void void___B([B a]); |
341 typedef void void___B_C([B a, C b]); | 336 typedef void void___B_C([B a, C b]); |
342 typedef void void___C_C([C a, C b]); | 337 typedef void void___C_C([C a, C b]); |
343 | 338 |
344 typedef void void____B({B a}); | 339 typedef void void____B({B a}); |
345 typedef void void____B_C({B a, C b}); | 340 typedef void void____B_C({B a, C b}); |
346 typedef void void____C_C({C a, C b}); | 341 typedef void void____C_C({C a, C b}); |
347 """).then((env) { | 342 """).then((env) { |
348 | 343 DartType Object_ = env['Object']; |
349 DartType Object_ = env['Object']; | 344 DartType Function_ = env['Function']; |
350 DartType Function_ = env['Function']; | 345 DartType dynamic__ = env['dynamic__']; |
351 DartType dynamic__ = env['dynamic__']; | 346 DartType void__ = env['void__']; |
352 DartType void__ = env['void__']; | 347 DartType A__ = env['A__']; |
353 DartType A__ = env['A__']; | 348 DartType B__ = env['B__']; |
354 DartType B__ = env['B__']; | 349 DartType C__ = env['C__']; |
355 DartType C__ = env['C__']; | 350 DartType void__A_B = env['void__A_B']; |
356 DartType void__A_B = env['void__A_B']; | 351 DartType void__A_C = env['void__A_C']; |
357 DartType void__A_C = env['void__A_C']; | 352 DartType void__B_A = env['void__B_A']; |
358 DartType void__B_A = env['void__B_A']; | 353 DartType void__B_C = env['void__B_C']; |
359 DartType void__B_C = env['void__B_C']; | 354 DartType void___B = env['void___B']; |
360 DartType void___B = env['void___B']; | 355 DartType void___B_C = env['void___B_C']; |
361 DartType void___B_C = env['void___B_C']; | 356 DartType void___C_C = env['void___C_C']; |
362 DartType void___C_C = env['void___C_C']; | 357 DartType void____B = env['void____B']; |
363 DartType void____B = env['void____B']; | 358 DartType void____B_C = env['void____B_C']; |
364 DartType void____B_C = env['void____B_C']; | 359 DartType void____C_C = env['void____C_C']; |
365 DartType void____C_C = env['void____C_C']; | 360 |
366 | 361 // Types used only for checking results. |
367 // Types used only for checking results. | 362 DartType void_ = env['void']; |
368 DartType void_ = env['void']; | 363 DartType B = env['B']; |
369 DartType B = env['B']; | 364 DartType C = env['C']; |
370 DartType C = env['C']; | 365 FunctionType Object__ = env.functionType(Object_, []); |
371 FunctionType Object__ = env.functionType(Object_, []); | 366 FunctionType void__Object_Object = |
372 FunctionType void__Object_Object = | 367 env.functionType(void_, [Object_, Object_]); |
373 env.functionType(void_, [Object_, Object_]); | 368 FunctionType void__Object_B = env.functionType(void_, [Object_, B]); |
374 FunctionType void__Object_B = | 369 FunctionType void__Object_C = env.functionType(void_, [Object_, C]); |
375 env.functionType(void_, [Object_, B]); | 370 FunctionType void__B_Object = env.functionType(void_, [B, Object_]); |
376 FunctionType void__Object_C = | 371 |
377 env.functionType(void_, [Object_, C]); | 372 checkLub(DartType a, DartType b, DartType expectedLub) { |
378 FunctionType void__B_Object = | 373 DartType lub = env.computeLeastUpperBound(a, b); |
379 env.functionType(void_, [B, Object_]); | 374 if (a != b) { |
380 | 375 expectedLub = expectedLub.unaliased; |
381 checkLub(DartType a, DartType b, DartType expectedLub) { | 376 lub = lub.unaliased; |
382 DartType lub = env.computeLeastUpperBound(a, b); | 377 } |
383 if (a != b) { | 378 Expect.equals( |
384 expectedLub = expectedLub.unaliased; | 379 expectedLub, |
385 lub = lub.unaliased; | 380 lub, |
386 } | 381 'Unexpected lub(${a.unaliased},' |
387 Expect.equals(expectedLub, lub, | 382 '${b.unaliased} = ' |
388 'Unexpected lub(${a.unaliased},' | 383 '${lub}, expected ${expectedLub}'); |
389 '${b.unaliased} = ' | 384 } |
390 '${lub}, expected ${expectedLub}'); | 385 |
391 } | 386 checkLub(Object_, Object_, Object_); |
392 | 387 checkLub(Object_, Function_, Object_); |
393 checkLub(Object_, Object_, Object_); | 388 checkLub(Object_, dynamic__, Object_); |
394 checkLub(Object_, Function_, Object_); | 389 checkLub(Object_, void__, Object_); |
395 checkLub(Object_, dynamic__, Object_); | 390 checkLub(Object_, A__, Object_); |
396 checkLub(Object_, void__, Object_); | 391 checkLub(Object_, B__, Object_); |
397 checkLub(Object_, A__, Object_); | 392 checkLub(Object_, C__, Object_); |
398 checkLub(Object_, B__, Object_); | 393 checkLub(Object_, void__A_B, Object_); |
399 checkLub(Object_, C__, Object_); | 394 checkLub(Object_, void__A_C, Object_); |
400 checkLub(Object_, void__A_B, Object_); | 395 checkLub(Object_, void__B_A, Object_); |
401 checkLub(Object_, void__A_C, Object_); | 396 checkLub(Object_, void__B_C, Object_); |
402 checkLub(Object_, void__B_A, Object_); | 397 checkLub(Object_, void___B, Object_); |
403 checkLub(Object_, void__B_C, Object_); | 398 checkLub(Object_, void___B_C, Object_); |
404 checkLub(Object_, void___B, Object_); | 399 checkLub(Object_, void___C_C, Object_); |
405 checkLub(Object_, void___B_C, Object_); | 400 checkLub(Object_, void____B, Object_); |
406 checkLub(Object_, void___C_C, Object_); | 401 checkLub(Object_, void____B_C, Object_); |
407 checkLub(Object_, void____B, Object_); | 402 checkLub(Object_, void____C_C, Object_); |
408 checkLub(Object_, void____B_C, Object_); | 403 |
409 checkLub(Object_, void____C_C, Object_); | 404 checkLub(Function_, Object_, Object_); |
410 | 405 checkLub(Function_, Function_, Function_); |
411 checkLub(Function_, Object_, Object_); | 406 checkLub(Function_, dynamic__, Function_); |
412 checkLub(Function_, Function_, Function_); | 407 checkLub(Function_, void__, Function_); |
413 checkLub(Function_, dynamic__, Function_); | 408 checkLub(Function_, A__, Function_); |
414 checkLub(Function_, void__, Function_); | 409 checkLub(Function_, B__, Function_); |
415 checkLub(Function_, A__, Function_); | 410 checkLub(Function_, C__, Function_); |
416 checkLub(Function_, B__, Function_); | 411 checkLub(Function_, void__A_B, Function_); |
417 checkLub(Function_, C__, Function_); | 412 checkLub(Function_, void__A_C, Function_); |
418 checkLub(Function_, void__A_B, Function_); | 413 checkLub(Function_, void__B_A, Function_); |
419 checkLub(Function_, void__A_C, Function_); | 414 checkLub(Function_, void__B_C, Function_); |
420 checkLub(Function_, void__B_A, Function_); | 415 checkLub(Function_, void___B, Function_); |
421 checkLub(Function_, void__B_C, Function_); | 416 checkLub(Function_, void___B_C, Function_); |
422 checkLub(Function_, void___B, Function_); | 417 checkLub(Function_, void___C_C, Function_); |
423 checkLub(Function_, void___B_C, Function_); | 418 checkLub(Function_, void____B, Function_); |
424 checkLub(Function_, void___C_C, Function_); | 419 checkLub(Function_, void____B_C, Function_); |
425 checkLub(Function_, void____B, Function_); | 420 checkLub(Function_, void____C_C, Function_); |
426 checkLub(Function_, void____B_C, Function_); | 421 |
427 checkLub(Function_, void____C_C, Function_); | 422 checkLub(dynamic__, Object_, Object_); |
428 | 423 checkLub(dynamic__, Function_, Function_); |
429 checkLub(dynamic__, Object_, Object_); | 424 checkLub(dynamic__, dynamic__, dynamic__); |
430 checkLub(dynamic__, Function_, Function_); | 425 checkLub(dynamic__, void__, dynamic__); |
431 checkLub(dynamic__, dynamic__, dynamic__); | 426 checkLub(dynamic__, A__, dynamic__); |
432 checkLub(dynamic__, void__, dynamic__); | 427 checkLub(dynamic__, B__, dynamic__); |
433 checkLub(dynamic__, A__, dynamic__); | 428 checkLub(dynamic__, C__, dynamic__); |
434 checkLub(dynamic__, B__, dynamic__); | 429 checkLub(dynamic__, void__A_B, Function_); |
435 checkLub(dynamic__, C__, dynamic__); | 430 checkLub(dynamic__, void__A_C, Function_); |
436 checkLub(dynamic__, void__A_B, Function_); | 431 checkLub(dynamic__, void__B_A, Function_); |
437 checkLub(dynamic__, void__A_C, Function_); | 432 checkLub(dynamic__, void__B_C, Function_); |
438 checkLub(dynamic__, void__B_A, Function_); | 433 checkLub(dynamic__, void___B, dynamic__); |
439 checkLub(dynamic__, void__B_C, Function_); | 434 checkLub(dynamic__, void___B_C, dynamic__); |
440 checkLub(dynamic__, void___B, dynamic__); | 435 checkLub(dynamic__, void___C_C, dynamic__); |
441 checkLub(dynamic__, void___B_C, dynamic__); | 436 checkLub(dynamic__, void____B, dynamic__); |
442 checkLub(dynamic__, void___C_C, dynamic__); | 437 checkLub(dynamic__, void____B_C, dynamic__); |
443 checkLub(dynamic__, void____B, dynamic__); | 438 checkLub(dynamic__, void____C_C, dynamic__); |
444 checkLub(dynamic__, void____B_C, dynamic__); | 439 |
445 checkLub(dynamic__, void____C_C, dynamic__); | 440 checkLub(void__, Object_, Object_); |
446 | 441 checkLub(void__, Function_, Function_); |
447 checkLub(void__, Object_, Object_); | 442 checkLub(void__, dynamic__, dynamic__); |
448 checkLub(void__, Function_, Function_); | 443 checkLub(void__, void__, void__); |
449 checkLub(void__, dynamic__, dynamic__); | 444 checkLub(void__, A__, void__); |
450 checkLub(void__, void__, void__); | 445 checkLub(void__, B__, void__); |
451 checkLub(void__, A__, void__); | 446 checkLub(void__, C__, void__); |
452 checkLub(void__, B__, void__); | 447 checkLub(void__, void__A_B, Function_); |
453 checkLub(void__, C__, void__); | 448 checkLub(void__, void__A_C, Function_); |
454 checkLub(void__, void__A_B, Function_); | 449 checkLub(void__, void__B_A, Function_); |
455 checkLub(void__, void__A_C, Function_); | 450 checkLub(void__, void__B_C, Function_); |
456 checkLub(void__, void__B_A, Function_); | 451 checkLub(void__, void___B, void__); |
457 checkLub(void__, void__B_C, Function_); | 452 checkLub(void__, void___B_C, void__); |
458 checkLub(void__, void___B, void__); | 453 checkLub(void__, void___C_C, void__); |
459 checkLub(void__, void___B_C, void__); | 454 checkLub(void__, void____B, void__); |
460 checkLub(void__, void___C_C, void__); | 455 checkLub(void__, void____B_C, void__); |
461 checkLub(void__, void____B, void__); | 456 checkLub(void__, void____C_C, void__); |
462 checkLub(void__, void____B_C, void__); | 457 |
463 checkLub(void__, void____C_C, void__); | 458 checkLub(A__, Object_, Object_); |
464 | 459 checkLub(A__, Function_, Function_); |
465 checkLub(A__, Object_, Object_); | 460 checkLub(A__, dynamic__, dynamic__); |
466 checkLub(A__, Function_, Function_); | 461 checkLub(A__, void__, void__); |
467 checkLub(A__, dynamic__, dynamic__); | 462 checkLub(A__, A__, A__); |
468 checkLub(A__, void__, void__); | 463 checkLub(A__, B__, Object__); |
469 checkLub(A__, A__, A__); | 464 checkLub(A__, C__, Object__); |
470 checkLub(A__, B__, Object__); | 465 checkLub(A__, void__A_B, Function_); |
471 checkLub(A__, C__, Object__); | 466 checkLub(A__, void__A_C, Function_); |
472 checkLub(A__, void__A_B, Function_); | 467 checkLub(A__, void__B_A, Function_); |
473 checkLub(A__, void__A_C, Function_); | 468 checkLub(A__, void__B_C, Function_); |
474 checkLub(A__, void__B_A, Function_); | 469 checkLub(A__, void___B, void__); |
475 checkLub(A__, void__B_C, Function_); | 470 checkLub(A__, void___B_C, void__); |
476 checkLub(A__, void___B, void__); | 471 checkLub(A__, void___C_C, void__); |
477 checkLub(A__, void___B_C, void__); | 472 checkLub(A__, void____B, void__); |
478 checkLub(A__, void___C_C, void__); | 473 checkLub(A__, void____B_C, void__); |
479 checkLub(A__, void____B, void__); | 474 checkLub(A__, void____C_C, void__); |
480 checkLub(A__, void____B_C, void__); | 475 |
481 checkLub(A__, void____C_C, void__); | 476 checkLub(B__, Object_, Object_); |
482 | 477 checkLub(B__, Function_, Function_); |
483 checkLub(B__, Object_, Object_); | 478 checkLub(B__, dynamic__, dynamic__); |
484 checkLub(B__, Function_, Function_); | 479 checkLub(B__, void__, void__); |
485 checkLub(B__, dynamic__, dynamic__); | 480 checkLub(B__, A__, Object__); |
486 checkLub(B__, void__, void__); | 481 checkLub(B__, B__, B__); |
487 checkLub(B__, A__, Object__); | 482 checkLub(B__, C__, B__); |
488 checkLub(B__, B__, B__); | 483 checkLub(B__, void__A_B, Function_); |
489 checkLub(B__, C__, B__); | 484 checkLub(B__, void__A_C, Function_); |
490 checkLub(B__, void__A_B, Function_); | 485 checkLub(B__, void__B_A, Function_); |
491 checkLub(B__, void__A_C, Function_); | 486 checkLub(B__, void__B_C, Function_); |
492 checkLub(B__, void__B_A, Function_); | 487 checkLub(B__, void___B, void__); |
493 checkLub(B__, void__B_C, Function_); | 488 checkLub(B__, void___B_C, void__); |
494 checkLub(B__, void___B, void__); | 489 checkLub(B__, void___C_C, void__); |
495 checkLub(B__, void___B_C, void__); | 490 checkLub(B__, void____B, void__); |
496 checkLub(B__, void___C_C, void__); | 491 checkLub(B__, void____B_C, void__); |
497 checkLub(B__, void____B, void__); | 492 checkLub(B__, void____C_C, void__); |
498 checkLub(B__, void____B_C, void__); | 493 |
499 checkLub(B__, void____C_C, void__); | 494 checkLub(C__, Object_, Object_); |
500 | 495 checkLub(C__, Function_, Function_); |
501 checkLub(C__, Object_, Object_); | 496 checkLub(C__, dynamic__, dynamic__); |
502 checkLub(C__, Function_, Function_); | 497 checkLub(C__, void__, void__); |
503 checkLub(C__, dynamic__, dynamic__); | 498 checkLub(C__, A__, Object__); |
504 checkLub(C__, void__, void__); | 499 checkLub(C__, B__, B__); |
505 checkLub(C__, A__, Object__); | 500 checkLub(C__, C__, C__); |
506 checkLub(C__, B__, B__); | 501 checkLub(C__, void__A_B, Function_); |
507 checkLub(C__, C__, C__); | 502 checkLub(C__, void__A_C, Function_); |
508 checkLub(C__, void__A_B, Function_); | 503 checkLub(C__, void__B_A, Function_); |
509 checkLub(C__, void__A_C, Function_); | 504 checkLub(C__, void__B_C, Function_); |
510 checkLub(C__, void__B_A, Function_); | 505 checkLub(C__, void___B, void__); |
511 checkLub(C__, void__B_C, Function_); | 506 checkLub(C__, void___B_C, void__); |
512 checkLub(C__, void___B, void__); | 507 checkLub(C__, void___C_C, void__); |
513 checkLub(C__, void___B_C, void__); | 508 checkLub(C__, void____B, void__); |
514 checkLub(C__, void___C_C, void__); | 509 checkLub(C__, void____B_C, void__); |
515 checkLub(C__, void____B, void__); | 510 checkLub(C__, void____C_C, void__); |
516 checkLub(C__, void____B_C, void__); | 511 |
517 checkLub(C__, void____C_C, void__); | 512 checkLub(void__A_B, Object_, Object_); |
518 | 513 checkLub(void__A_B, Function_, Function_); |
519 checkLub(void__A_B, Object_, Object_); | 514 checkLub(void__A_B, dynamic__, Function_); |
520 checkLub(void__A_B, Function_, Function_); | 515 checkLub(void__A_B, void__, Function_); |
521 checkLub(void__A_B, dynamic__, Function_); | 516 checkLub(void__A_B, A__, Function_); |
522 checkLub(void__A_B, void__, Function_); | 517 checkLub(void__A_B, B__, Function_); |
523 checkLub(void__A_B, A__, Function_); | 518 checkLub(void__A_B, C__, Function_); |
524 checkLub(void__A_B, B__, Function_); | 519 checkLub(void__A_B, void__A_B, void__A_B); |
525 checkLub(void__A_B, C__, Function_); | 520 checkLub(void__A_B, void__A_C, void__A_B); |
526 checkLub(void__A_B, void__A_B, void__A_B); | 521 checkLub(void__A_B, void__B_A, void__Object_Object); |
527 checkLub(void__A_B, void__A_C, void__A_B); | 522 checkLub(void__A_B, void__B_C, void__Object_B); |
528 checkLub(void__A_B, void__B_A, void__Object_Object); | 523 checkLub(void__A_B, void___B, Function_); |
529 checkLub(void__A_B, void__B_C, void__Object_B); | 524 checkLub(void__A_B, void___B_C, Function_); |
530 checkLub(void__A_B, void___B, Function_); | 525 checkLub(void__A_B, void___C_C, Function_); |
531 checkLub(void__A_B, void___B_C, Function_); | 526 checkLub(void__A_B, void____B, Function_); |
532 checkLub(void__A_B, void___C_C, Function_); | 527 checkLub(void__A_B, void____B_C, Function_); |
533 checkLub(void__A_B, void____B, Function_); | 528 checkLub(void__A_B, void____C_C, Function_); |
534 checkLub(void__A_B, void____B_C, Function_); | 529 |
535 checkLub(void__A_B, void____C_C, Function_); | 530 checkLub(void__A_C, Object_, Object_); |
536 | 531 checkLub(void__A_C, Function_, Function_); |
537 checkLub(void__A_C, Object_, Object_); | 532 checkLub(void__A_C, dynamic__, Function_); |
538 checkLub(void__A_C, Function_, Function_); | 533 checkLub(void__A_C, void__, Function_); |
539 checkLub(void__A_C, dynamic__, Function_); | 534 checkLub(void__A_C, A__, Function_); |
540 checkLub(void__A_C, void__, Function_); | 535 checkLub(void__A_C, B__, Function_); |
541 checkLub(void__A_C, A__, Function_); | 536 checkLub(void__A_C, C__, Function_); |
542 checkLub(void__A_C, B__, Function_); | 537 checkLub(void__A_C, void__A_B, void__A_B); |
543 checkLub(void__A_C, C__, Function_); | 538 checkLub(void__A_C, void__A_C, void__A_C); |
544 checkLub(void__A_C, void__A_B, void__A_B); | 539 checkLub(void__A_C, void__B_A, void__Object_Object); |
545 checkLub(void__A_C, void__A_C, void__A_C); | 540 checkLub(void__A_C, void__B_C, void__Object_C); |
546 checkLub(void__A_C, void__B_A, void__Object_Object); | 541 checkLub(void__A_C, void___B, Function_); |
547 checkLub(void__A_C, void__B_C, void__Object_C); | 542 checkLub(void__A_C, void___B_C, Function_); |
548 checkLub(void__A_C, void___B, Function_); | 543 checkLub(void__A_C, void___C_C, Function_); |
549 checkLub(void__A_C, void___B_C, Function_); | 544 checkLub(void__A_C, void____B, Function_); |
550 checkLub(void__A_C, void___C_C, Function_); | 545 checkLub(void__A_C, void____B_C, Function_); |
551 checkLub(void__A_C, void____B, Function_); | 546 checkLub(void__A_C, void____C_C, Function_); |
552 checkLub(void__A_C, void____B_C, Function_); | 547 |
553 checkLub(void__A_C, void____C_C, Function_); | 548 checkLub(void__B_A, Object_, Object_); |
554 | 549 checkLub(void__B_A, Function_, Function_); |
555 checkLub(void__B_A, Object_, Object_); | 550 checkLub(void__B_A, dynamic__, Function_); |
556 checkLub(void__B_A, Function_, Function_); | 551 checkLub(void__B_A, void__, Function_); |
557 checkLub(void__B_A, dynamic__, Function_); | 552 checkLub(void__B_A, A__, Function_); |
558 checkLub(void__B_A, void__, Function_); | 553 checkLub(void__B_A, B__, Function_); |
559 checkLub(void__B_A, A__, Function_); | 554 checkLub(void__B_A, C__, Function_); |
560 checkLub(void__B_A, B__, Function_); | 555 checkLub(void__B_A, void__A_B, void__Object_Object); |
561 checkLub(void__B_A, C__, Function_); | 556 checkLub(void__B_A, void__A_C, void__Object_Object); |
562 checkLub(void__B_A, void__A_B, void__Object_Object); | 557 checkLub(void__B_A, void__B_A, void__B_A); |
563 checkLub(void__B_A, void__A_C, void__Object_Object); | 558 checkLub(void__B_A, void__B_C, void__B_Object); |
564 checkLub(void__B_A, void__B_A, void__B_A); | 559 checkLub(void__B_A, void___B, Function_); |
565 checkLub(void__B_A, void__B_C, void__B_Object); | 560 checkLub(void__B_A, void___B_C, Function_); |
566 checkLub(void__B_A, void___B, Function_); | 561 checkLub(void__B_A, void___C_C, Function_); |
567 checkLub(void__B_A, void___B_C, Function_); | 562 checkLub(void__B_A, void____B, Function_); |
568 checkLub(void__B_A, void___C_C, Function_); | 563 checkLub(void__B_A, void____B_C, Function_); |
569 checkLub(void__B_A, void____B, Function_); | 564 checkLub(void__B_A, void____C_C, Function_); |
570 checkLub(void__B_A, void____B_C, Function_); | 565 |
571 checkLub(void__B_A, void____C_C, Function_); | 566 checkLub(void__B_C, Object_, Object_); |
572 | 567 checkLub(void__B_C, Function_, Function_); |
573 checkLub(void__B_C, Object_, Object_); | 568 checkLub(void__B_C, dynamic__, Function_); |
574 checkLub(void__B_C, Function_, Function_); | 569 checkLub(void__B_C, void__, Function_); |
575 checkLub(void__B_C, dynamic__, Function_); | 570 checkLub(void__B_C, A__, Function_); |
576 checkLub(void__B_C, void__, Function_); | 571 checkLub(void__B_C, B__, Function_); |
577 checkLub(void__B_C, A__, Function_); | 572 checkLub(void__B_C, C__, Function_); |
578 checkLub(void__B_C, B__, Function_); | 573 checkLub(void__B_C, void__A_B, void__Object_B); |
579 checkLub(void__B_C, C__, Function_); | 574 checkLub(void__B_C, void__A_C, void__Object_C); |
580 checkLub(void__B_C, void__A_B, void__Object_B); | 575 checkLub(void__B_C, void__B_A, void__B_Object); |
581 checkLub(void__B_C, void__A_C, void__Object_C); | 576 checkLub(void__B_C, void__B_C, void__B_C); |
582 checkLub(void__B_C, void__B_A, void__B_Object); | 577 checkLub(void__B_C, void___B, Function_); |
583 checkLub(void__B_C, void__B_C, void__B_C); | 578 checkLub(void__B_C, void___B_C, Function_); |
584 checkLub(void__B_C, void___B, Function_); | 579 checkLub(void__B_C, void___C_C, Function_); |
585 checkLub(void__B_C, void___B_C, Function_); | 580 checkLub(void__B_C, void____B, Function_); |
586 checkLub(void__B_C, void___C_C, Function_); | 581 checkLub(void__B_C, void____B_C, Function_); |
587 checkLub(void__B_C, void____B, Function_); | 582 checkLub(void__B_C, void____C_C, Function_); |
588 checkLub(void__B_C, void____B_C, Function_); | 583 |
589 checkLub(void__B_C, void____C_C, Function_); | 584 checkLub(void___B, Object_, Object_); |
590 | 585 checkLub(void___B, Function_, Function_); |
591 checkLub(void___B, Object_, Object_); | 586 checkLub(void___B, dynamic__, dynamic__); |
592 checkLub(void___B, Function_, Function_); | 587 checkLub(void___B, void__, void__); |
593 checkLub(void___B, dynamic__, dynamic__); | 588 checkLub(void___B, A__, void__); |
594 checkLub(void___B, void__, void__); | 589 checkLub(void___B, B__, void__); |
595 checkLub(void___B, A__, void__); | 590 checkLub(void___B, C__, void__); |
596 checkLub(void___B, B__, void__); | 591 checkLub(void___B, void__A_B, Function_); |
597 checkLub(void___B, C__, void__); | 592 checkLub(void___B, void__A_C, Function_); |
598 checkLub(void___B, void__A_B, Function_); | 593 checkLub(void___B, void__B_A, Function_); |
599 checkLub(void___B, void__A_C, Function_); | 594 checkLub(void___B, void__B_C, Function_); |
600 checkLub(void___B, void__B_A, Function_); | 595 checkLub(void___B, void___B, void___B); |
601 checkLub(void___B, void__B_C, Function_); | 596 checkLub(void___B, void___B_C, void___B); |
602 checkLub(void___B, void___B, void___B); | 597 checkLub(void___B, void___C_C, void___B); |
603 checkLub(void___B, void___B_C, void___B); | 598 checkLub(void___B, void____B, void__); |
604 checkLub(void___B, void___C_C, void___B); | 599 checkLub(void___B, void____B_C, void__); |
605 checkLub(void___B, void____B, void__); | 600 checkLub(void___B, void____C_C, void__); |
606 checkLub(void___B, void____B_C, void__); | 601 |
607 checkLub(void___B, void____C_C, void__); | 602 checkLub(void___B_C, Object_, Object_); |
608 | 603 checkLub(void___B_C, Function_, Function_); |
609 checkLub(void___B_C, Object_, Object_); | 604 checkLub(void___B_C, dynamic__, dynamic__); |
610 checkLub(void___B_C, Function_, Function_); | 605 checkLub(void___B_C, void__, void__); |
611 checkLub(void___B_C, dynamic__, dynamic__); | 606 checkLub(void___B_C, A__, void__); |
612 checkLub(void___B_C, void__, void__); | 607 checkLub(void___B_C, B__, void__); |
613 checkLub(void___B_C, A__, void__); | 608 checkLub(void___B_C, C__, void__); |
614 checkLub(void___B_C, B__, void__); | 609 checkLub(void___B_C, void__A_B, Function_); |
615 checkLub(void___B_C, C__, void__); | 610 checkLub(void___B_C, void__A_C, Function_); |
616 checkLub(void___B_C, void__A_B, Function_); | 611 checkLub(void___B_C, void__B_A, Function_); |
617 checkLub(void___B_C, void__A_C, Function_); | 612 checkLub(void___B_C, void__B_C, Function_); |
618 checkLub(void___B_C, void__B_A, Function_); | 613 checkLub(void___B_C, void___B, void___B); |
619 checkLub(void___B_C, void__B_C, Function_); | 614 checkLub(void___B_C, void___B_C, void___B_C); |
620 checkLub(void___B_C, void___B, void___B); | 615 checkLub(void___B_C, void___C_C, void___B_C); |
621 checkLub(void___B_C, void___B_C, void___B_C); | 616 checkLub(void___B_C, void____B, void__); |
622 checkLub(void___B_C, void___C_C, void___B_C); | 617 checkLub(void___B_C, void____B_C, void__); |
623 checkLub(void___B_C, void____B, void__); | 618 checkLub(void___B_C, void____C_C, void__); |
624 checkLub(void___B_C, void____B_C, void__); | 619 |
625 checkLub(void___B_C, void____C_C, void__); | 620 checkLub(void___C_C, Object_, Object_); |
626 | 621 checkLub(void___C_C, Function_, Function_); |
627 checkLub(void___C_C, Object_, Object_); | 622 checkLub(void___C_C, dynamic__, dynamic__); |
628 checkLub(void___C_C, Function_, Function_); | 623 checkLub(void___C_C, void__, void__); |
629 checkLub(void___C_C, dynamic__, dynamic__); | 624 checkLub(void___C_C, A__, void__); |
630 checkLub(void___C_C, void__, void__); | 625 checkLub(void___C_C, B__, void__); |
631 checkLub(void___C_C, A__, void__); | 626 checkLub(void___C_C, C__, void__); |
632 checkLub(void___C_C, B__, void__); | 627 checkLub(void___C_C, void__A_B, Function_); |
633 checkLub(void___C_C, C__, void__); | 628 checkLub(void___C_C, void__A_C, Function_); |
634 checkLub(void___C_C, void__A_B, Function_); | 629 checkLub(void___C_C, void__B_A, Function_); |
635 checkLub(void___C_C, void__A_C, Function_); | 630 checkLub(void___C_C, void__B_C, Function_); |
636 checkLub(void___C_C, void__B_A, Function_); | 631 checkLub(void___C_C, void___B, void___B); |
637 checkLub(void___C_C, void__B_C, Function_); | 632 checkLub(void___C_C, void___B_C, void___B_C); |
638 checkLub(void___C_C, void___B, void___B); | 633 checkLub(void___C_C, void___C_C, void___C_C); |
639 checkLub(void___C_C, void___B_C, void___B_C); | 634 checkLub(void___C_C, void____B, void__); |
640 checkLub(void___C_C, void___C_C, void___C_C); | 635 checkLub(void___C_C, void____B_C, void__); |
641 checkLub(void___C_C, void____B, void__); | 636 checkLub(void___C_C, void____C_C, void__); |
642 checkLub(void___C_C, void____B_C, void__); | 637 |
643 checkLub(void___C_C, void____C_C, void__); | 638 checkLub(void____B, Object_, Object_); |
644 | 639 checkLub(void____B, Function_, Function_); |
645 checkLub(void____B, Object_, Object_); | 640 checkLub(void____B, dynamic__, dynamic__); |
646 checkLub(void____B, Function_, Function_); | 641 checkLub(void____B, void__, void__); |
647 checkLub(void____B, dynamic__, dynamic__); | 642 checkLub(void____B, A__, void__); |
648 checkLub(void____B, void__, void__); | 643 checkLub(void____B, B__, void__); |
649 checkLub(void____B, A__, void__); | 644 checkLub(void____B, C__, void__); |
650 checkLub(void____B, B__, void__); | 645 checkLub(void____B, void__A_B, Function_); |
651 checkLub(void____B, C__, void__); | 646 checkLub(void____B, void__A_C, Function_); |
652 checkLub(void____B, void__A_B, Function_); | 647 checkLub(void____B, void__B_A, Function_); |
653 checkLub(void____B, void__A_C, Function_); | 648 checkLub(void____B, void__B_C, Function_); |
654 checkLub(void____B, void__B_A, Function_); | 649 checkLub(void____B, void___B, void__); |
655 checkLub(void____B, void__B_C, Function_); | 650 checkLub(void____B, void___B_C, void__); |
656 checkLub(void____B, void___B, void__); | 651 checkLub(void____B, void___C_C, void__); |
657 checkLub(void____B, void___B_C, void__); | 652 checkLub(void____B, void____B, void____B); |
658 checkLub(void____B, void___C_C, void__); | 653 checkLub(void____B, void____B_C, void____B); |
659 checkLub(void____B, void____B, void____B); | 654 checkLub(void____B, void____C_C, void____B); |
660 checkLub(void____B, void____B_C, void____B); | 655 |
661 checkLub(void____B, void____C_C, void____B); | 656 checkLub(void____B_C, Object_, Object_); |
662 | 657 checkLub(void____B_C, Function_, Function_); |
663 checkLub(void____B_C, Object_, Object_); | 658 checkLub(void____B_C, dynamic__, dynamic__); |
664 checkLub(void____B_C, Function_, Function_); | 659 checkLub(void____B_C, void__, void__); |
665 checkLub(void____B_C, dynamic__, dynamic__); | 660 checkLub(void____B_C, A__, void__); |
666 checkLub(void____B_C, void__, void__); | 661 checkLub(void____B_C, B__, void__); |
667 checkLub(void____B_C, A__, void__); | 662 checkLub(void____B_C, C__, void__); |
668 checkLub(void____B_C, B__, void__); | 663 checkLub(void____B_C, void__A_B, Function_); |
669 checkLub(void____B_C, C__, void__); | 664 checkLub(void____B_C, void__A_C, Function_); |
670 checkLub(void____B_C, void__A_B, Function_); | 665 checkLub(void____B_C, void__B_A, Function_); |
671 checkLub(void____B_C, void__A_C, Function_); | 666 checkLub(void____B_C, void__B_C, Function_); |
672 checkLub(void____B_C, void__B_A, Function_); | 667 checkLub(void____B_C, void___B, void__); |
673 checkLub(void____B_C, void__B_C, Function_); | 668 checkLub(void____B_C, void___B_C, void__); |
674 checkLub(void____B_C, void___B, void__); | 669 checkLub(void____B_C, void___C_C, void__); |
675 checkLub(void____B_C, void___B_C, void__); | 670 checkLub(void____B_C, void____B, void____B); |
676 checkLub(void____B_C, void___C_C, void__); | 671 checkLub(void____B_C, void____B_C, void____B_C); |
677 checkLub(void____B_C, void____B, void____B); | 672 checkLub(void____B_C, void____C_C, void____B_C); |
678 checkLub(void____B_C, void____B_C, void____B_C); | 673 |
679 checkLub(void____B_C, void____C_C, void____B_C); | 674 checkLub(void____C_C, Object_, Object_); |
680 | 675 checkLub(void____C_C, Function_, Function_); |
681 checkLub(void____C_C, Object_, Object_); | 676 checkLub(void____C_C, dynamic__, dynamic__); |
682 checkLub(void____C_C, Function_, Function_); | 677 checkLub(void____C_C, void__, void__); |
683 checkLub(void____C_C, dynamic__, dynamic__); | 678 checkLub(void____C_C, A__, void__); |
684 checkLub(void____C_C, void__, void__); | 679 checkLub(void____C_C, B__, void__); |
685 checkLub(void____C_C, A__, void__); | 680 checkLub(void____C_C, C__, void__); |
686 checkLub(void____C_C, B__, void__); | 681 checkLub(void____C_C, void__A_B, Function_); |
687 checkLub(void____C_C, C__, void__); | 682 checkLub(void____C_C, void__A_C, Function_); |
688 checkLub(void____C_C, void__A_B, Function_); | 683 checkLub(void____C_C, void__B_A, Function_); |
689 checkLub(void____C_C, void__A_C, Function_); | 684 checkLub(void____C_C, void__B_C, Function_); |
690 checkLub(void____C_C, void__B_A, Function_); | 685 checkLub(void____C_C, void___B, void__); |
691 checkLub(void____C_C, void__B_C, Function_); | 686 checkLub(void____C_C, void___B_C, void__); |
692 checkLub(void____C_C, void___B, void__); | 687 checkLub(void____C_C, void___C_C, void__); |
693 checkLub(void____C_C, void___B_C, void__); | 688 checkLub(void____C_C, void____B, void____B); |
694 checkLub(void____C_C, void___C_C, void__); | 689 checkLub(void____C_C, void____B_C, void____B_C); |
695 checkLub(void____C_C, void____B, void____B); | 690 checkLub(void____C_C, void____C_C, void____C_C); |
696 checkLub(void____C_C, void____B_C, void____B_C); | 691 })); |
697 checkLub(void____C_C, void____C_C, void____C_C); | |
698 })); | |
699 } | 692 } |
700 | 693 |
701 void testTypeVariable() { | 694 void testTypeVariable() { |
702 asyncTest(() => TypeEnvironment.create(r""" | 695 asyncTest(() => TypeEnvironment.create(r""" |
703 class A {} | 696 class A {} |
704 class B {} | 697 class B {} |
705 class C extends B {} | 698 class C extends B {} |
706 class I<S extends A, | 699 class I<S extends A, |
707 T extends B, | 700 T extends B, |
708 U extends C, | 701 U extends C, |
709 V extends T, | 702 V extends T, |
710 W extends V, | 703 W extends V, |
711 X extends T> {} | 704 X extends T> {} |
712 """).then((env) { | 705 """).then((env) { |
| 706 // A B |
| 707 // | / \ |
| 708 // S T C |
| 709 // / \ \ |
| 710 // V X U |
| 711 // / |
| 712 // W |
713 | 713 |
714 // A B | 714 DartType Object_ = env['Object']; |
715 // | / \ | 715 DartType A = env['A']; |
716 // S T C | 716 DartType B = env['B']; |
717 // / \ \ | 717 DartType C = env['C']; |
718 // V X U | 718 ClassElement I = env.getElement('I'); |
719 // / | 719 DartType S = I.typeVariables[0]; |
720 // W | 720 DartType T = I.typeVariables[1]; |
| 721 DartType U = I.typeVariables[2]; |
| 722 DartType V = I.typeVariables[3]; |
| 723 DartType W = I.typeVariables[4]; |
| 724 DartType X = I.typeVariables[5]; |
721 | 725 |
722 DartType Object_ = env['Object']; | 726 checkLub(DartType a, DartType b, DartType expectedLub) { |
723 DartType A = env['A']; | 727 DartType lub = env.computeLeastUpperBound(a, b); |
724 DartType B = env['B']; | 728 Expect.equals(expectedLub, lub, |
725 DartType C = env['C']; | 729 'Unexpected lub($a,$b) = $lub, expected $expectedLub'); |
726 ClassElement I = env.getElement('I'); | 730 } |
727 DartType S = I.typeVariables[0]; | |
728 DartType T = I.typeVariables[1]; | |
729 DartType U = I.typeVariables[2]; | |
730 DartType V = I.typeVariables[3]; | |
731 DartType W = I.typeVariables[4]; | |
732 DartType X = I.typeVariables[5]; | |
733 | 731 |
734 checkLub(DartType a, DartType b, DartType expectedLub) { | 732 checkLub(Object_, Object_, Object_); |
735 DartType lub = env.computeLeastUpperBound(a, b); | 733 checkLub(Object_, A, Object_); |
736 Expect.equals(expectedLub, lub, | 734 checkLub(Object_, B, Object_); |
737 'Unexpected lub($a,$b) = $lub, expected $expectedLub'); | 735 checkLub(Object_, C, Object_); |
738 } | 736 checkLub(Object_, S, Object_); |
| 737 checkLub(Object_, T, Object_); |
| 738 checkLub(Object_, U, Object_); |
| 739 checkLub(Object_, V, Object_); |
| 740 checkLub(Object_, W, Object_); |
| 741 checkLub(Object_, X, Object_); |
739 | 742 |
740 checkLub(Object_, Object_, Object_); | 743 checkLub(A, Object_, Object_); |
741 checkLub(Object_, A, Object_); | 744 checkLub(A, A, A); |
742 checkLub(Object_, B, Object_); | 745 checkLub(A, B, Object_); |
743 checkLub(Object_, C, Object_); | 746 checkLub(A, C, Object_); |
744 checkLub(Object_, S, Object_); | 747 checkLub(A, S, A); |
745 checkLub(Object_, T, Object_); | 748 checkLub(A, T, Object_); |
746 checkLub(Object_, U, Object_); | 749 checkLub(A, U, Object_); |
747 checkLub(Object_, V, Object_); | 750 checkLub(A, V, Object_); |
748 checkLub(Object_, W, Object_); | 751 checkLub(A, W, Object_); |
749 checkLub(Object_, X, Object_); | 752 checkLub(A, X, Object_); |
750 | 753 |
751 checkLub(A, Object_, Object_); | 754 checkLub(B, Object_, Object_); |
752 checkLub(A, A, A); | 755 checkLub(B, A, Object_); |
753 checkLub(A, B, Object_); | 756 checkLub(B, B, B); |
754 checkLub(A, C, Object_); | 757 checkLub(B, C, B); |
755 checkLub(A, S, A); | 758 checkLub(B, S, Object_); |
756 checkLub(A, T, Object_); | 759 checkLub(B, T, B); |
757 checkLub(A, U, Object_); | 760 checkLub(B, U, B); |
758 checkLub(A, V, Object_); | 761 checkLub(B, V, B); |
759 checkLub(A, W, Object_); | 762 checkLub(B, W, B); |
760 checkLub(A, X, Object_); | 763 checkLub(B, X, B); |
761 | 764 |
762 checkLub(B, Object_, Object_); | 765 checkLub(C, Object_, Object_); |
763 checkLub(B, A, Object_); | 766 checkLub(C, A, Object_); |
764 checkLub(B, B, B); | 767 checkLub(C, B, B); |
765 checkLub(B, C, B); | 768 checkLub(C, C, C); |
766 checkLub(B, S, Object_); | 769 checkLub(C, S, Object_); |
767 checkLub(B, T, B); | 770 checkLub(C, T, B); |
768 checkLub(B, U, B); | 771 checkLub(C, U, C); |
769 checkLub(B, V, B); | 772 checkLub(C, V, B); |
770 checkLub(B, W, B); | 773 checkLub(C, W, B); |
771 checkLub(B, X, B); | 774 checkLub(C, X, B); |
772 | 775 |
773 checkLub(C, Object_, Object_); | 776 checkLub(S, Object_, Object_); |
774 checkLub(C, A, Object_); | 777 checkLub(S, A, A); |
775 checkLub(C, B, B); | 778 checkLub(S, B, Object_); |
776 checkLub(C, C, C); | 779 checkLub(S, C, Object_); |
777 checkLub(C, S, Object_); | 780 checkLub(S, S, S); |
778 checkLub(C, T, B); | 781 checkLub(S, T, Object_); |
779 checkLub(C, U, C); | 782 checkLub(S, U, Object_); |
780 checkLub(C, V, B); | 783 checkLub(S, V, Object_); |
781 checkLub(C, W, B); | 784 checkLub(S, W, Object_); |
782 checkLub(C, X, B); | 785 checkLub(S, X, Object_); |
783 | 786 |
784 checkLub(S, Object_, Object_); | 787 checkLub(T, Object_, Object_); |
785 checkLub(S, A, A); | 788 checkLub(T, A, Object_); |
786 checkLub(S, B, Object_); | 789 checkLub(T, B, B); |
787 checkLub(S, C, Object_); | 790 checkLub(T, C, B); |
788 checkLub(S, S, S); | 791 checkLub(T, S, Object_); |
789 checkLub(S, T, Object_); | 792 checkLub(T, T, T); |
790 checkLub(S, U, Object_); | 793 checkLub(T, U, B); |
791 checkLub(S, V, Object_); | 794 checkLub(T, V, T); |
792 checkLub(S, W, Object_); | 795 checkLub(T, W, T); |
793 checkLub(S, X, Object_); | 796 checkLub(T, X, T); |
794 | 797 |
795 checkLub(T, Object_, Object_); | 798 checkLub(U, Object_, Object_); |
796 checkLub(T, A, Object_); | 799 checkLub(U, A, Object_); |
797 checkLub(T, B, B); | 800 checkLub(U, B, B); |
798 checkLub(T, C, B); | 801 checkLub(U, C, C); |
799 checkLub(T, S, Object_); | 802 checkLub(U, S, Object_); |
800 checkLub(T, T, T); | 803 checkLub(U, T, B); |
801 checkLub(T, U, B); | 804 checkLub(U, U, U); |
802 checkLub(T, V, T); | 805 checkLub(U, V, B); |
803 checkLub(T, W, T); | 806 checkLub(U, W, B); |
804 checkLub(T, X, T); | 807 checkLub(U, X, B); |
805 | 808 |
806 checkLub(U, Object_, Object_); | 809 checkLub(V, Object_, Object_); |
807 checkLub(U, A, Object_); | 810 checkLub(V, A, Object_); |
808 checkLub(U, B, B); | 811 checkLub(V, B, B); |
809 checkLub(U, C, C); | 812 checkLub(V, C, B); |
810 checkLub(U, S, Object_); | 813 checkLub(V, S, Object_); |
811 checkLub(U, T, B); | 814 checkLub(V, T, T); |
812 checkLub(U, U, U); | 815 checkLub(V, U, B); |
813 checkLub(U, V, B); | 816 checkLub(V, V, V); |
814 checkLub(U, W, B); | 817 checkLub(V, W, V); |
815 checkLub(U, X, B); | 818 checkLub(V, X, T); |
816 | 819 |
817 checkLub(V, Object_, Object_); | 820 checkLub(W, Object_, Object_); |
818 checkLub(V, A, Object_); | 821 checkLub(W, A, Object_); |
819 checkLub(V, B, B); | 822 checkLub(W, B, B); |
820 checkLub(V, C, B); | 823 checkLub(W, C, B); |
821 checkLub(V, S, Object_); | 824 checkLub(W, S, Object_); |
822 checkLub(V, T, T); | 825 checkLub(W, T, T); |
823 checkLub(V, U, B); | 826 checkLub(W, U, B); |
824 checkLub(V, V, V); | 827 checkLub(W, V, V); |
825 checkLub(V, W, V); | 828 checkLub(W, W, W); |
826 checkLub(V, X, T); | 829 checkLub(W, X, T); |
827 | 830 |
828 checkLub(W, Object_, Object_); | 831 checkLub(X, Object_, Object_); |
829 checkLub(W, A, Object_); | 832 checkLub(X, A, Object_); |
830 checkLub(W, B, B); | 833 checkLub(X, B, B); |
831 checkLub(W, C, B); | 834 checkLub(X, C, B); |
832 checkLub(W, S, Object_); | 835 checkLub(X, S, Object_); |
833 checkLub(W, T, T); | 836 checkLub(X, T, T); |
834 checkLub(W, U, B); | 837 checkLub(X, U, B); |
835 checkLub(W, V, V); | 838 checkLub(X, V, T); |
836 checkLub(W, W, W); | 839 checkLub(X, W, T); |
837 checkLub(W, X, T); | 840 checkLub(X, X, X); |
838 | 841 })); |
839 checkLub(X, Object_, Object_); | |
840 checkLub(X, A, Object_); | |
841 checkLub(X, B, B); | |
842 checkLub(X, C, B); | |
843 checkLub(X, S, Object_); | |
844 checkLub(X, T, T); | |
845 checkLub(X, U, B); | |
846 checkLub(X, V, T); | |
847 checkLub(X, W, T); | |
848 checkLub(X, X, X); | |
849 })); | |
850 } | 842 } |
851 | |
852 | |
OLD | NEW |