Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: tests/compiler/dart2js/subtype_test.dart

Issue 26546005: Add more specific relation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 subtype_test; 5 library subtype_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 'type_test_helper.dart'; 9 import 'type_test_helper.dart';
10 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart'; 10 import '../../../sdk/lib/_internal/compiler/implementation/dart_types.dart';
11 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t" 11 import "../../../sdk/lib/_internal/compiler/implementation/elements/elements.dar t"
12 show Element, ClassElement; 12 show Element, ClassElement;
13 13
14 void main() { 14 void main() {
15 testInterfaceSubtype(); 15 testInterfaceSubtype();
16 testCallableSubtype(); 16 testCallableSubtype();
17 testFunctionSubtyping(); 17 testFunctionSubtyping();
18 testTypedefSubtyping(); 18 testTypedefSubtyping();
19 testFunctionSubtypingOptional(); 19 testFunctionSubtypingOptional();
20 testTypedefSubtypingOptional(); 20 testTypedefSubtypingOptional();
21 testFunctionSubtypingNamed(); 21 testFunctionSubtypingNamed();
22 testTypedefSubtypingNamed(); 22 testTypedefSubtypingNamed();
23 testTypeVariableSubtype(); 23 testTypeVariableSubtype();
24 } 24 }
25 25
26 void testTypes(TypeEnvironment env, DartType subtype, DartType supertype,
27 bool expectSubtype, bool expectMoreSpecific) {
28 if (expectMoreSpecific == null) expectMoreSpecific = expectSubtype;
29 Expect.equals(expectSubtype, env.isSubtype(subtype, supertype),
30 '$subtype <: $supertype');
31 Expect.equals(expectMoreSpecific, env.isMoreSpecific(subtype, supertype),
32 '$subtype << $supertype');
33 }
34
35 void testElementTypes(TypeEnvironment env, String subname, String supername,
36 bool expectSubtype, bool expectMoreSpecific) {
37 DartType subtype = env.getElementType(subname);
38 DartType supertype = env.getElementType(supername);
39 testTypes(env, subtype, supertype, expectSubtype, expectMoreSpecific);
40 }
41
42
26 void testInterfaceSubtype() { 43 void testInterfaceSubtype() {
27 asyncTest(() => TypeEnvironment.create(r""" 44 asyncTest(() => TypeEnvironment.create(r"""
28 class A<T> {} 45 class A<T> {}
29 class B<T1, T2> extends A<T1> {} 46 class B<T1, T2> extends A<T1> {}
30 // TODO(johnniwinther): Inheritance with different type arguments is 47 // TODO(johnniwinther): Inheritance with different type arguments is
31 // currently not supported by the implementation. 48 // currently not supported by the implementation.
32 class C<T1, T2> extends B<T2, T1> /*implements A<A<T1>>*/ {} 49 class C<T1, T2> extends B<T2, T1> /*implements A<A<T1>>*/ {}
33 """).then((env) { 50 """).then((env) {
34 51
35 void expect(bool value, DartType T, DartType S) { 52 void expect(bool expectSubtype, DartType T, DartType S,
36 Expect.equals(value, env.isSubtype(T, S), '$T <: $S'); 53 {bool expectMoreSpecific}) {
54 testTypes(env, T, S, expectSubtype, expectMoreSpecific);
37 } 55 }
38 56
39 ClassElement A = env.getElement('A'); 57 ClassElement A = env.getElement('A');
40 ClassElement B = env.getElement('B'); 58 ClassElement B = env.getElement('B');
41 ClassElement C = env.getElement('C'); 59 ClassElement C = env.getElement('C');
42 DartType Object_ = env['Object']; 60 DartType Object_ = env['Object'];
43 DartType num_ = env['num']; 61 DartType num_ = env['num'];
44 DartType int_ = env['int']; 62 DartType int_ = env['int'];
45 DartType String_ = env['String']; 63 DartType String_ = env['String'];
46 DartType dynamic_ = env['dynamic']; 64 DartType dynamic_ = env['dynamic'];
(...skipping 15 matching lines...) Expand all
62 expect(true, int_, int_); 80 expect(true, int_, int_);
63 expect(false, String_, int_); 81 expect(false, String_, int_);
64 expect(true, dynamic_, int_); 82 expect(true, dynamic_, int_);
65 83
66 expect(false, Object_, String_); 84 expect(false, Object_, String_);
67 expect(false, num_, String_); 85 expect(false, num_, String_);
68 expect(false, int_, String_); 86 expect(false, int_, String_);
69 expect(true, String_, String_); 87 expect(true, String_, String_);
70 expect(true, dynamic_, String_); 88 expect(true, dynamic_, String_);
71 89
72 expect(true, Object_, dynamic_); 90 expect(true, Object_, dynamic_, expectMoreSpecific: false);
73 expect(true, num_, dynamic_); 91 expect(true, num_, dynamic_, expectMoreSpecific: false);
74 expect(true, int_, dynamic_); 92 expect(true, int_, dynamic_, expectMoreSpecific: false);
75 expect(true, String_, dynamic_); 93 expect(true, String_, dynamic_, expectMoreSpecific: false);
76 expect(true, dynamic_, dynamic_); 94 expect(true, dynamic_, dynamic_);
77 95
78 DartType A_Object = instantiate(A, [Object_]); 96 DartType A_Object = instantiate(A, [Object_]);
79 DartType A_num = instantiate(A, [num_]); 97 DartType A_num = instantiate(A, [num_]);
80 DartType A_int = instantiate(A, [int_]); 98 DartType A_int = instantiate(A, [int_]);
81 DartType A_String = instantiate(A, [String_]); 99 DartType A_String = instantiate(A, [String_]);
82 DartType A_dynamic = instantiate(A, [dynamic_]); 100 DartType A_dynamic = instantiate(A, [dynamic_]);
83 101
84 expect(true, A_Object, Object_); 102 expect(true, A_Object, Object_);
85 expect(false, A_Object, num_); 103 expect(false, A_Object, num_);
86 expect(false, A_Object, int_); 104 expect(false, A_Object, int_);
87 expect(false, A_Object, String_); 105 expect(false, A_Object, String_);
88 expect(true, A_Object, dynamic_); 106 expect(true, A_Object, dynamic_, expectMoreSpecific: false);
89 107
90 expect(true, A_Object, A_Object); 108 expect(true, A_Object, A_Object);
91 expect(true, A_num, A_Object); 109 expect(true, A_num, A_Object);
92 expect(true, A_int, A_Object); 110 expect(true, A_int, A_Object);
93 expect(true, A_String, A_Object); 111 expect(true, A_String, A_Object);
94 expect(true, A_dynamic, A_Object); 112 expect(true, A_dynamic, A_Object);
95 113
96 expect(false, A_Object, A_num); 114 expect(false, A_Object, A_num);
97 expect(true, A_num, A_num); 115 expect(true, A_num, A_num);
98 expect(true, A_int, A_num); 116 expect(true, A_int, A_num);
99 expect(false, A_String, A_num); 117 expect(false, A_String, A_num);
100 expect(true, A_dynamic, A_num); 118 expect(true, A_dynamic, A_num);
101 119
102 expect(false, A_Object, A_int); 120 expect(false, A_Object, A_int);
103 expect(false, A_num, A_int); 121 expect(false, A_num, A_int);
104 expect(true, A_int, A_int); 122 expect(true, A_int, A_int);
105 expect(false, A_String, A_int); 123 expect(false, A_String, A_int);
106 expect(true, A_dynamic, A_int); 124 expect(true, A_dynamic, A_int);
107 125
108 expect(false, A_Object, A_String); 126 expect(false, A_Object, A_String);
109 expect(false, A_num, A_String); 127 expect(false, A_num, A_String);
110 expect(false, A_int, A_String); 128 expect(false, A_int, A_String);
111 expect(true, A_String, A_String); 129 expect(true, A_String, A_String);
112 expect(true, A_dynamic, A_String); 130 expect(true, A_dynamic, A_String);
113 131
114 expect(true, A_Object, A_dynamic); 132 expect(true, A_Object, A_dynamic, expectMoreSpecific: false);
115 expect(true, A_num, A_dynamic); 133 expect(true, A_num, A_dynamic, expectMoreSpecific: false);
116 expect(true, A_int, A_dynamic); 134 expect(true, A_int, A_dynamic, expectMoreSpecific: false);
117 expect(true, A_String, A_dynamic); 135 expect(true, A_String, A_dynamic, expectMoreSpecific: false);
118 expect(true, A_dynamic, A_dynamic); 136 expect(true, A_dynamic, A_dynamic);
119 137
120 DartType B_Object_Object = instantiate(B, [Object_, Object_]); 138 DartType B_Object_Object = instantiate(B, [Object_, Object_]);
121 DartType B_num_num = instantiate(B, [num_, num_]); 139 DartType B_num_num = instantiate(B, [num_, num_]);
122 DartType B_int_num = instantiate(B, [int_, num_]); 140 DartType B_int_num = instantiate(B, [int_, num_]);
123 DartType B_dynamic_dynamic = instantiate(B, [dynamic_, dynamic_]); 141 DartType B_dynamic_dynamic = instantiate(B, [dynamic_, dynamic_]);
124 DartType B_String_dynamic = instantiate(B, [String_, dynamic_]); 142 DartType B_String_dynamic = instantiate(B, [String_, dynamic_]);
125 143
126 expect(true, B_Object_Object, Object_); 144 expect(true, B_Object_Object, Object_);
127 expect(true, B_Object_Object, A_Object); 145 expect(true, B_Object_Object, A_Object);
128 expect(false, B_Object_Object, A_num); 146 expect(false, B_Object_Object, A_num);
129 expect(false, B_Object_Object, A_int); 147 expect(false, B_Object_Object, A_int);
130 expect(false, B_Object_Object, A_String); 148 expect(false, B_Object_Object, A_String);
131 expect(true, B_Object_Object, A_dynamic); 149 expect(true, B_Object_Object, A_dynamic, expectMoreSpecific: false);
132 150
133 expect(true, B_num_num, Object_); 151 expect(true, B_num_num, Object_);
134 expect(true, B_num_num, A_Object); 152 expect(true, B_num_num, A_Object);
135 expect(true, B_num_num, A_num); 153 expect(true, B_num_num, A_num);
136 expect(false, B_num_num, A_int); 154 expect(false, B_num_num, A_int);
137 expect(false, B_num_num, A_String); 155 expect(false, B_num_num, A_String);
138 expect(true, B_num_num, A_dynamic); 156 expect(true, B_num_num, A_dynamic, expectMoreSpecific: false);
139 157
140 expect(true, B_int_num, Object_); 158 expect(true, B_int_num, Object_);
141 expect(true, B_int_num, A_Object); 159 expect(true, B_int_num, A_Object);
142 expect(true, B_int_num, A_num); 160 expect(true, B_int_num, A_num);
143 expect(true, B_int_num, A_int); 161 expect(true, B_int_num, A_int);
144 expect(false, B_int_num, A_String); 162 expect(false, B_int_num, A_String);
145 expect(true, B_int_num, A_dynamic); 163 expect(true, B_int_num, A_dynamic, expectMoreSpecific: false);
146 164
147 expect(true, B_dynamic_dynamic, Object_); 165 expect(true, B_dynamic_dynamic, Object_);
148 expect(true, B_dynamic_dynamic, A_Object); 166 expect(true, B_dynamic_dynamic, A_Object);
149 expect(true, B_dynamic_dynamic, A_num); 167 expect(true, B_dynamic_dynamic, A_num);
150 expect(true, B_dynamic_dynamic, A_int); 168 expect(true, B_dynamic_dynamic, A_int);
151 expect(true, B_dynamic_dynamic, A_String); 169 expect(true, B_dynamic_dynamic, A_String);
152 expect(true, B_dynamic_dynamic, A_dynamic); 170 expect(true, B_dynamic_dynamic, A_dynamic);
153 171
154 expect(true, B_String_dynamic, Object_); 172 expect(true, B_String_dynamic, Object_);
155 expect(true, B_String_dynamic, A_Object); 173 expect(true, B_String_dynamic, A_Object);
156 expect(false, B_String_dynamic, A_num); 174 expect(false, B_String_dynamic, A_num);
157 expect(false, B_String_dynamic, A_int); 175 expect(false, B_String_dynamic, A_int);
158 expect(true, B_String_dynamic, A_String); 176 expect(true, B_String_dynamic, A_String);
159 expect(true, B_String_dynamic, A_dynamic); 177 expect(true, B_String_dynamic, A_dynamic, expectMoreSpecific: false);
160 178
161 expect(true, B_Object_Object, B_Object_Object); 179 expect(true, B_Object_Object, B_Object_Object);
162 expect(true, B_num_num, B_Object_Object); 180 expect(true, B_num_num, B_Object_Object);
163 expect(true, B_int_num, B_Object_Object); 181 expect(true, B_int_num, B_Object_Object);
164 expect(true, B_dynamic_dynamic, B_Object_Object); 182 expect(true, B_dynamic_dynamic, B_Object_Object);
165 expect(true, B_String_dynamic, B_Object_Object); 183 expect(true, B_String_dynamic, B_Object_Object);
166 184
167 expect(false, B_Object_Object, B_num_num); 185 expect(false, B_Object_Object, B_num_num);
168 expect(true, B_num_num, B_num_num); 186 expect(true, B_num_num, B_num_num);
169 expect(true, B_int_num, B_num_num); 187 expect(true, B_int_num, B_num_num);
170 expect(true, B_dynamic_dynamic, B_num_num); 188 expect(true, B_dynamic_dynamic, B_num_num);
171 expect(false, B_String_dynamic, B_num_num); 189 expect(false, B_String_dynamic, B_num_num);
172 190
173 expect(false, B_Object_Object, B_int_num); 191 expect(false, B_Object_Object, B_int_num);
174 expect(false, B_num_num, B_int_num); 192 expect(false, B_num_num, B_int_num);
175 expect(true, B_int_num, B_int_num); 193 expect(true, B_int_num, B_int_num);
176 expect(true, B_dynamic_dynamic, B_int_num); 194 expect(true, B_dynamic_dynamic, B_int_num);
177 expect(false, B_String_dynamic, B_int_num); 195 expect(false, B_String_dynamic, B_int_num);
178 196
179 expect(true, B_Object_Object, B_dynamic_dynamic); 197 expect(true, B_Object_Object, B_dynamic_dynamic, expectMoreSpecific: false);
180 expect(true, B_num_num, B_dynamic_dynamic); 198 expect(true, B_num_num, B_dynamic_dynamic, expectMoreSpecific: false);
181 expect(true, B_int_num, B_dynamic_dynamic); 199 expect(true, B_int_num, B_dynamic_dynamic, expectMoreSpecific: false);
182 expect(true, B_dynamic_dynamic, B_dynamic_dynamic); 200 expect(true, B_dynamic_dynamic, B_dynamic_dynamic);
183 expect(true, B_String_dynamic, B_dynamic_dynamic); 201 expect(true, B_String_dynamic, B_dynamic_dynamic,
202 expectMoreSpecific: false);
184 203
185 expect(false, B_Object_Object, B_String_dynamic); 204 expect(false, B_Object_Object, B_String_dynamic);
186 expect(false, B_num_num, B_String_dynamic); 205 expect(false, B_num_num, B_String_dynamic);
187 expect(false, B_int_num, B_String_dynamic); 206 expect(false, B_int_num, B_String_dynamic);
188 expect(true, B_dynamic_dynamic, B_String_dynamic); 207 expect(true, B_dynamic_dynamic, B_String_dynamic);
189 expect(true, B_String_dynamic, B_String_dynamic); 208 expect(true, B_String_dynamic, B_String_dynamic);
190 209
191 DartType C_Object_Object = instantiate(C, [Object_, Object_]); 210 DartType C_Object_Object = instantiate(C, [Object_, Object_]);
192 DartType C_num_num = instantiate(C, [num_, num_]); 211 DartType C_num_num = instantiate(C, [num_, num_]);
193 DartType C_int_String = instantiate(C, [int_, String_]); 212 DartType C_int_String = instantiate(C, [int_, String_]);
194 DartType C_dynamic_dynamic = instantiate(C, [dynamic_, dynamic_]); 213 DartType C_dynamic_dynamic = instantiate(C, [dynamic_, dynamic_]);
195 214
196 expect(true, C_Object_Object, B_Object_Object); 215 expect(true, C_Object_Object, B_Object_Object);
197 expect(false, C_Object_Object, B_num_num); 216 expect(false, C_Object_Object, B_num_num);
198 expect(false, C_Object_Object, B_int_num); 217 expect(false, C_Object_Object, B_int_num);
199 expect(true, C_Object_Object, B_dynamic_dynamic); 218 expect(true, C_Object_Object, B_dynamic_dynamic, expectMoreSpecific: false);
200 expect(false, C_Object_Object, B_String_dynamic); 219 expect(false, C_Object_Object, B_String_dynamic);
201 220
202 expect(true, C_num_num, B_Object_Object); 221 expect(true, C_num_num, B_Object_Object);
203 expect(true, C_num_num, B_num_num); 222 expect(true, C_num_num, B_num_num);
204 expect(false, C_num_num, B_int_num); 223 expect(false, C_num_num, B_int_num);
205 expect(true, C_num_num, B_dynamic_dynamic); 224 expect(true, C_num_num, B_dynamic_dynamic, expectMoreSpecific: false);
206 expect(false, C_num_num, B_String_dynamic); 225 expect(false, C_num_num, B_String_dynamic);
207 226
208 expect(true, C_int_String, B_Object_Object); 227 expect(true, C_int_String, B_Object_Object);
209 expect(false, C_int_String, B_num_num); 228 expect(false, C_int_String, B_num_num);
210 expect(false, C_int_String, B_int_num); 229 expect(false, C_int_String, B_int_num);
211 expect(true, C_int_String, B_dynamic_dynamic); 230 expect(true, C_int_String, B_dynamic_dynamic, expectMoreSpecific: false);
212 expect(true, C_int_String, B_String_dynamic); 231 expect(true, C_int_String, B_String_dynamic, expectMoreSpecific: false);
213 232
214 expect(true, C_dynamic_dynamic, B_Object_Object); 233 expect(true, C_dynamic_dynamic, B_Object_Object);
215 expect(true, C_dynamic_dynamic, B_num_num); 234 expect(true, C_dynamic_dynamic, B_num_num);
216 expect(true, C_dynamic_dynamic, B_int_num); 235 expect(true, C_dynamic_dynamic, B_int_num);
217 expect(true, C_dynamic_dynamic, B_dynamic_dynamic); 236 expect(true, C_dynamic_dynamic, B_dynamic_dynamic);
218 expect(true, C_dynamic_dynamic, B_String_dynamic); 237 expect(true, C_dynamic_dynamic, B_String_dynamic);
219 238
220 expect(false, C_int_String, A_int); 239 expect(false, C_int_String, A_int);
221 expect(true, C_int_String, A_String); 240 expect(true, C_int_String, A_String);
222 // TODO(johnniwinther): Inheritance with different type arguments is 241 // TODO(johnniwinther): Inheritance with different type arguments is
(...skipping 11 matching lines...) Expand all
234 class A { 253 class A {
235 int call(V v, int i); 254 int call(V v, int i);
236 255
237 int m1(U u, int i); 256 int m1(U u, int i);
238 int m2(W w, num n); 257 int m2(W w, num n);
239 U m3(V v, int i); 258 U m3(V v, int i);
240 int m4(V v, U u); 259 int m4(V v, U u);
241 void m5(V v, int i); 260 void m5(V v, int i);
242 } 261 }
243 """).then((env) { 262 """).then((env) {
244 void expect(bool value, DartType T, DartType S) { 263 void expect(bool expectSubtype, DartType T, DartType S,
245 Expect.equals(value, env.isSubtype(T, S), '$T <: $S'); 264 {bool expectMoreSpecific}) {
265 testTypes(env, T, S, expectSubtype, expectMoreSpecific);
246 } 266 }
247 267
248 ClassElement classA = env.getElement('A'); 268 ClassElement classA = env.getElement('A');
249 DartType A = classA.rawType; 269 DartType A = classA.rawType;
250 DartType function = env['Function']; 270 DartType function = env['Function'];
251 DartType m1 = env.getMemberType(classA, 'm1'); 271 DartType m1 = env.getMemberType(classA, 'm1');
252 DartType m2 = env.getMemberType(classA, 'm2'); 272 DartType m2 = env.getMemberType(classA, 'm2');
253 DartType m3 = env.getMemberType(classA, 'm3'); 273 DartType m3 = env.getMemberType(classA, 'm3');
254 DartType m4 = env.getMemberType(classA, 'm4'); 274 DartType m4 = env.getMemberType(classA, 'm4');
255 DartType m5 = env.getMemberType(classA, 'm5'); 275 DartType m5 = env.getMemberType(classA, 'm5');
256 276
257 expect(true, A, function); 277 expect(true, A, function, expectMoreSpecific: false);
258 expect(true, A, m1); 278 expect(true, A, m1, expectMoreSpecific: false);
259 expect(true, A, m2); 279 expect(true, A, m2, expectMoreSpecific: false);
260 expect(false, A, m3); 280 expect(false, A, m3);
261 expect(false, A, m4); 281 expect(false, A, m4);
262 expect(true, A, m5); 282 expect(true, A, m5, expectMoreSpecific: false);
263 })); 283 }));
264 } 284 }
265 285
266 testFunctionSubtyping() { 286 testFunctionSubtyping() {
267 asyncTest(() => TypeEnvironment.create(r""" 287 asyncTest(() => TypeEnvironment.create(r"""
268 _() => null; 288 _() => null;
269 void void_() {} 289 void void_() {}
270 void void_2() {} 290 void void_2() {}
271 int int_() => 0; 291 int int_() => 0;
272 int int_2() => 0; 292 int int_2() => 0;
(...skipping 26 matching lines...) Expand all
299 typedef int int__Object(Object o); 319 typedef int int__Object(Object o);
300 typedef Object Object__int(int i); 320 typedef Object Object__int(int i);
301 typedef int int__double(double d); 321 typedef int int__double(double d);
302 typedef int int__int_int(int i1, int i2); 322 typedef int int__int_int(int i1, int i2);
303 typedef void inline_void_(void f()); 323 typedef void inline_void_(void f());
304 typedef void inline_void__int(void f(int i)); 324 typedef void inline_void__int(void f(int i));
305 """).then(functionSubtypingHelper)); 325 """).then(functionSubtypingHelper));
306 } 326 }
307 327
308 functionSubtypingHelper(TypeEnvironment env) { 328 functionSubtypingHelper(TypeEnvironment env) {
309 void expect(bool expectedResult, String sub, String sup) { 329 void expect(bool expectSubtype, String sub, String sup,
310 DartType subtype = env.getElementType(sub); 330 {bool expectMoreSpecific}) {
311 DartType supertype = env.getElementType(sup); 331 testElementTypes(env, sub, sup, expectSubtype, expectMoreSpecific);
312 Expect.equals(expectedResult, env.isSubtype(subtype, supertype),
313 '$subtype <: $supertype');
314 } 332 }
315 333
316 // () -> int <: Function 334 // () -> int <: Function
317 expect(true, 'int_', 'Function'); 335 expect(true, 'int_', 'Function');
318 // Function <: () -> int 336 // Function <: () -> int
319 expect(false, 'Function', 'int_'); 337 expect(false, 'Function', 'int_');
320 338
321 // () -> dynamic <: () -> dynamic 339 // () -> dynamic <: () -> dynamic
322 expect(true, '_', '_'); 340 expect(true, '_', '_');
323 // () -> dynamic <: () -> void 341 // () -> dynamic <: () -> void
324 expect(true, '_', 'void_'); 342 expect(true, '_', 'void_');
325 // () -> void <: () -> dynamic 343 // () -> void <: () -> dynamic
326 expect(true, 'void_', '_'); 344 expect(true, 'void_', '_', expectMoreSpecific: false);
327 345
328 // () -> int <: () -> void 346 // () -> int <: () -> void
329 expect(true, 'int_', 'void_'); 347 expect(true, 'int_', 'void_');
330 // () -> void <: () -> int 348 // () -> void <: () -> int
331 expect(false, 'void_', 'int_'); 349 expect(false, 'void_', 'int_');
332 // () -> void <: () -> void 350 // () -> void <: () -> void
333 expect(true, 'void_', 'void_2'); 351 expect(true, 'void_', 'void_2');
334 // () -> int <: () -> int 352 // () -> int <: () -> int
335 expect(true, 'int_', 'int_2'); 353 expect(true, 'int_', 'int_2');
336 // () -> int <: () -> Object 354 // () -> int <: () -> Object
337 expect(true, 'int_', 'Object_'); 355 expect(true, 'int_', 'Object_');
338 // () -> int <: () -> double 356 // () -> int <: () -> double
339 expect(false, 'int_', 'double_'); 357 expect(false, 'int_', 'double_');
340 // () -> int <: (int) -> void 358 // () -> int <: (int) -> void
341 expect(false, 'int_', 'void__int'); 359 expect(false, 'int_', 'void__int');
342 // () -> void <: (int) -> int 360 // () -> void <: (int) -> int
343 expect(false, 'void_', 'int__int'); 361 expect(false, 'void_', 'int__int');
344 // () -> void <: (int) -> void 362 // () -> void <: (int) -> void
345 expect(false, 'void_', 'void__int'); 363 expect(false, 'void_', 'void__int');
346 // (int) -> int <: (int) -> int 364 // (int) -> int <: (int) -> int
347 expect(true, 'int__int', 'int__int2'); 365 expect(true, 'int__int', 'int__int2');
348 // (Object) -> int <: (int) -> Object 366 // (Object) -> int <: (int) -> Object
349 expect(true, 'int__Object', 'Object__int'); 367 expect(true, 'int__Object', 'Object__int', expectMoreSpecific: false);
350 // (int) -> int <: (double) -> int 368 // (int) -> int <: (double) -> int
351 expect(false, 'int__int', 'int__double'); 369 expect(false, 'int__int', 'int__double');
352 // () -> int <: (int) -> int 370 // () -> int <: (int) -> int
353 expect(false, 'int_', 'int__int'); 371 expect(false, 'int_', 'int__int');
354 // (int) -> int <: (int,int) -> int 372 // (int) -> int <: (int,int) -> int
355 expect(false, 'int__int', 'int__int_int'); 373 expect(false, 'int__int', 'int__int_int');
356 // (int,int) -> int <: (int) -> int 374 // (int,int) -> int <: (int) -> int
357 expect(false, 'int__int_int', 'int__int'); 375 expect(false, 'int__int_int', 'int__int');
358 // (()->void) -> void <: ((int)->void) -> void 376 // (()->void) -> void <: ((int)->void) -> void
359 expect(false, 'inline_void_', 'inline_void__int'); 377 expect(false, 'inline_void_', 'inline_void__int');
(...skipping 29 matching lines...) Expand all
389 typedef void void__int__int2(int i1, [int i2]); 407 typedef void void__int__int2(int i1, [int i2]);
390 typedef void void__int__int_int(int i1, [int i2, int i3]); 408 typedef void void__int__int_int(int i1, [int i2, int i3]);
391 typedef void void___double(double d); 409 typedef void void___double(double d);
392 typedef void void___int_int([int i1, int i2]); 410 typedef void void___int_int([int i1, int i2]);
393 typedef void void___int_int_int([int i1, int i2, int i3]); 411 typedef void void___int_int_int([int i1, int i2, int i3]);
394 typedef void void___Object_int([Object o, int i]); 412 typedef void void___Object_int([Object o, int i]);
395 """).then(functionSubtypingOptionalHelper)); 413 """).then(functionSubtypingOptionalHelper));
396 } 414 }
397 415
398 functionSubtypingOptionalHelper(TypeEnvironment env) { 416 functionSubtypingOptionalHelper(TypeEnvironment env) {
399 expect(bool expectedResult, String sub, String sup) { 417 void expect(bool expectSubtype, String sub, String sup,
400 DartType subtype = env.getElementType(sub); 418 {bool expectMoreSpecific}) {
401 DartType supertype = env.getElementType(sup); 419 testElementTypes(env, sub, sup, expectSubtype, expectMoreSpecific);
402 Expect.equals(expectedResult, env.isSubtype(subtype, supertype),
403 '$subtype <: $supertype');
404 } 420 }
405 421
406 // Test ([int])->void <: ()->void. 422 // Test ([int])->void <: ()->void.
407 expect(true, 'void___int', 'void_'); 423 expect(true, 'void___int', 'void_');
408 // Test ([int])->void <: (int)->void. 424 // Test ([int])->void <: (int)->void.
409 expect(true, 'void___int', 'void__int'); 425 expect(true, 'void___int', 'void__int');
410 // Test (int)->void <: ([int])->void. 426 // Test (int)->void <: ([int])->void.
411 expect(false, 'void__int', 'void___int'); 427 expect(false, 'void__int', 'void___int');
412 // Test ([int])->void <: ([int])->void. 428 // Test ([int])->void <: ([int])->void.
413 expect(true, 'void___int', 'void___int2'); 429 expect(true, 'void___int', 'void___int2');
414 // Test ([Object])->void <: ([int])->void. 430 // Test ([Object])->void <: ([int])->void.
415 expect(true, 'void___Object', 'void___int'); 431 expect(true, 'void___Object', 'void___int', expectMoreSpecific: false);
416 // Test ([int])->void <: ([Object])->void. 432 // Test ([int])->void <: ([Object])->void.
417 expect(true, 'void___int', 'void___Object'); 433 expect(true, 'void___int', 'void___Object');
418 // Test (int,[int])->void <: (int)->void. 434 // Test (int,[int])->void <: (int)->void.
419 expect(true, 'void__int__int', 'void__int'); 435 expect(true, 'void__int__int', 'void__int');
420 // Test (int,[int])->void <: (int,[int])->void. 436 // Test (int,[int])->void <: (int,[int])->void.
421 expect(true, 'void__int__int', 'void__int__int2'); 437 expect(true, 'void__int__int', 'void__int__int2');
422 // Test (int)->void <: ([int])->void. 438 // Test (int)->void <: ([int])->void.
423 expect(false, 'void__int', 'void___int'); 439 expect(false, 'void__int', 'void___int');
424 // Test ([int,int])->void <: (int)->void. 440 // Test ([int,int])->void <: (int)->void.
425 expect(true, 'void___int_int', 'void__int'); 441 expect(true, 'void___int_int', 'void__int');
426 // Test ([int,int])->void <: (int,[int])->void. 442 // Test ([int,int])->void <: (int,[int])->void.
427 expect(true, 'void___int_int', 'void__int__int'); 443 expect(true, 'void___int_int', 'void__int__int');
428 // Test ([int,int])->void <: (int,[int,int])->void. 444 // Test ([int,int])->void <: (int,[int,int])->void.
429 expect(false, 'void___int_int', 'void__int__int_int'); 445 expect(false, 'void___int_int', 'void__int__int_int');
430 // Test ([int,int,int])->void <: (int,[int,int])->void. 446 // Test ([int,int,int])->void <: (int,[int,int])->void.
431 expect(true, 'void___int_int_int', 'void__int__int_int'); 447 expect(true, 'void___int_int_int', 'void__int__int_int');
432 // Test ([int])->void <: ([double])->void. 448 // Test ([int])->void <: ([double])->void.
433 expect(false, 'void___int', 'void___double'); 449 expect(false, 'void___int', 'void___double');
434 // Test ([int])->void <: ([int,int])->void. 450 // Test ([int])->void <: ([int,int])->void.
435 expect(false, 'void___int', 'void___int_int'); 451 expect(false, 'void___int', 'void___int_int');
436 // Test ([int,int])->void <: ([int])->void. 452 // Test ([int,int])->void <: ([int])->void.
437 expect(true, 'void___int_int', 'void___int'); 453 expect(true, 'void___int_int', 'void___int');
438 // Test ([Object,int])->void <: ([int])->void. 454 // Test ([Object,int])->void <: ([int])->void.
439 expect(true, 'void___Object_int', 'void___int'); 455 expect(true, 'void___Object_int', 'void___int', expectMoreSpecific: false);
440 } 456 }
441 457
442 testFunctionSubtypingNamed() { 458 testFunctionSubtypingNamed() {
443 asyncTest(() => TypeEnvironment.create(r""" 459 asyncTest(() => TypeEnvironment.create(r"""
444 void void_() {} 460 void void_() {}
445 void void__int(int i) {} 461 void void__int(int i) {}
446 void void___a_int({int a}) {} 462 void void___a_int({int a}) {}
447 void void___a_int2({int a}) {} 463 void void___a_int2({int a}) {}
448 void void___b_int({int b}) {} 464 void void___b_int({int b}) {}
449 void void___a_Object({Object a}) {} 465 void void___a_Object({Object a}) {}
(...skipping 21 matching lines...) Expand all
471 typedef void void___a_double({double a}); 487 typedef void void___a_double({double a});
472 typedef void void___a_int_b_int({int a, int b}); 488 typedef void void___a_int_b_int({int a, int b});
473 typedef void void___a_int_b_int_c_int({int a, int b, int c}); 489 typedef void void___a_int_b_int_c_int({int a, int b, int c});
474 typedef void void___a_int_c_int({int a, int c}); 490 typedef void void___a_int_c_int({int a, int c});
475 typedef void void___b_int_c_int({int b, int c}); 491 typedef void void___b_int_c_int({int b, int c});
476 typedef void void___c_int({int c}); 492 typedef void void___c_int({int c});
477 """).then(functionSubtypingNamedHelper)); 493 """).then(functionSubtypingNamedHelper));
478 } 494 }
479 495
480 functionSubtypingNamedHelper(TypeEnvironment env) { 496 functionSubtypingNamedHelper(TypeEnvironment env) {
481 expect(bool expectedResult, String sub, String sup) { 497 expect(bool expectSubtype, String sub, String sup,
482 DartType subtype = env.getElementType(sub); 498 {bool expectMoreSpecific}) {
483 DartType supertype = env.getElementType(sup); 499 testElementTypes(env, sub, sup, expectSubtype, expectMoreSpecific);
484 Expect.equals(expectedResult, env.isSubtype(subtype, supertype),
485 '$subtype <: $supertype');
486 } 500 }
487 501
488 // Test ({int a})->void <: ()->void. 502 // Test ({int a})->void <: ()->void.
489 expect(true, 'void___a_int', 'void_'); 503 expect(true, 'void___a_int', 'void_');
490 // Test ({int a})->void <: (int)->void. 504 // Test ({int a})->void <: (int)->void.
491 expect(false, 'void___a_int', 'void__int'); 505 expect(false, 'void___a_int', 'void__int');
492 // Test (int)->void <: ({int a})->void. 506 // Test (int)->void <: ({int a})->void.
493 expect(false, 'void__int', 'void___a_int'); 507 expect(false, 'void__int', 'void___a_int');
494 // Test ({int a})->void <: ({int a})->void. 508 // Test ({int a})->void <: ({int a})->void.
495 expect(true, 'void___a_int', 'void___a_int2'); 509 expect(true, 'void___a_int', 'void___a_int2');
496 // Test ({int a})->void <: ({int b})->void. 510 // Test ({int a})->void <: ({int b})->void.
497 expect(false, 'void___a_int', 'void___b_int'); 511 expect(false, 'void___a_int', 'void___b_int');
498 // Test ({Object a})->void <: ({int a})->void. 512 // Test ({Object a})->void <: ({int a})->void.
499 expect(true, 'void___a_Object', 'void___a_int'); 513 expect(true, 'void___a_Object', 'void___a_int', expectMoreSpecific: false);
500 // Test ({int a})->void <: ({Object a})->void. 514 // Test ({int a})->void <: ({Object a})->void.
501 expect(true, 'void___a_int', 'void___a_Object'); 515 expect(true, 'void___a_int', 'void___a_Object');
502 // Test (int,{int a})->void <: (int,{int a})->void. 516 // Test (int,{int a})->void <: (int,{int a})->void.
503 expect(true, 'void__int__a_int', 'void__int__a_int2'); 517 expect(true, 'void__int__a_int', 'void__int__a_int2');
504 // Test ({int a})->void <: ({double a})->void. 518 // Test ({int a})->void <: ({double a})->void.
505 expect(false, 'void___a_int', 'void___a_double'); 519 expect(false, 'void___a_int', 'void___a_double');
506 // Test ({int a})->void <: ({int a,int b})->void. 520 // Test ({int a})->void <: ({int a,int b})->void.
507 expect(false, 'void___a_int', 'void___a_int_b_int'); 521 expect(false, 'void___a_int', 'void___a_int_b_int');
508 // Test ({int a,int b})->void <: ({int a})->void. 522 // Test ({int a,int b})->void <: ({int a})->void.
509 expect(true, 'void___a_int_b_int', 'void___a_int'); 523 expect(true, 'void___a_int_b_int', 'void___a_int');
(...skipping 11 matching lines...) Expand all
521 class B<T extends Object> {} 535 class B<T extends Object> {}
522 class C<T extends num> {} 536 class C<T extends num> {}
523 class D<T extends int> {} 537 class D<T extends int> {}
524 class E<T extends S, S extends num> {} 538 class E<T extends S, S extends num> {}
525 class F<T extends num, S extends T> {} 539 class F<T extends num, S extends T> {}
526 class G<T extends T> {} 540 class G<T extends T> {}
527 class H<T extends S, S extends T> {} 541 class H<T extends S, S extends T> {}
528 class I<T extends S, S extends U, U extends T> {} 542 class I<T extends S, S extends U, U extends T> {}
529 class J<T extends S, S extends U, U extends S> {} 543 class J<T extends S, S extends U, U extends S> {}
530 """).then((env) { 544 """).then((env) {
531 void expect(bool value, DartType T, DartType S) { 545 void expect(bool expectSubtype, DartType T, DartType S,
532 Expect.equals(value, env.isSubtype(T, S), '$T <: $S'); 546 {bool expectMoreSpecific}) {
547 testTypes(env, T, S, expectSubtype, expectMoreSpecific);
533 } 548 }
534 549
535 ClassElement A = env.getElement('A'); 550 ClassElement A = env.getElement('A');
536 TypeVariableType A_T = A.thisType.typeArguments.head; 551 TypeVariableType A_T = A.thisType.typeArguments.head;
537 ClassElement B = env.getElement('B'); 552 ClassElement B = env.getElement('B');
538 TypeVariableType B_T = B.thisType.typeArguments.head; 553 TypeVariableType B_T = B.thisType.typeArguments.head;
539 ClassElement C = env.getElement('C'); 554 ClassElement C = env.getElement('C');
540 TypeVariableType C_T = C.thisType.typeArguments.head; 555 TypeVariableType C_T = C.thisType.typeArguments.head;
541 ClassElement D = env.getElement('D'); 556 ClassElement D = env.getElement('D');
542 TypeVariableType D_T = D.thisType.typeArguments.head; 557 TypeVariableType D_T = D.thisType.typeArguments.head;
(...skipping 21 matching lines...) Expand all
564 DartType num_ = env['num']; 579 DartType num_ = env['num'];
565 DartType int_ = env['int']; 580 DartType int_ = env['int'];
566 DartType String_ = env['String']; 581 DartType String_ = env['String'];
567 DartType dynamic_ = env['dynamic']; 582 DartType dynamic_ = env['dynamic'];
568 583
569 // class A<T> {} 584 // class A<T> {}
570 expect(true, A_T, Object_); 585 expect(true, A_T, Object_);
571 expect(false, A_T, num_); 586 expect(false, A_T, num_);
572 expect(false, A_T, int_); 587 expect(false, A_T, int_);
573 expect(false, A_T, String_); 588 expect(false, A_T, String_);
574 expect(true, A_T, dynamic_); 589 expect(true, A_T, dynamic_, expectMoreSpecific: false);
575 expect(true, A_T, A_T); 590 expect(true, A_T, A_T);
576 expect(false, A_T, B_T); 591 expect(false, A_T, B_T);
577 592
578 // class B<T extends Object> {} 593 // class B<T extends Object> {}
579 expect(true, B_T, Object_); 594 expect(true, B_T, Object_);
580 expect(false, B_T, num_); 595 expect(false, B_T, num_);
581 expect(false, B_T, int_); 596 expect(false, B_T, int_);
582 expect(false, B_T, String_); 597 expect(false, B_T, String_);
583 expect(true, B_T, dynamic_); 598 expect(true, B_T, dynamic_, expectMoreSpecific: false);
584 expect(true, B_T, B_T); 599 expect(true, B_T, B_T);
585 expect(false, B_T, A_T); 600 expect(false, B_T, A_T);
586 601
587 // class C<T extends num> {} 602 // class C<T extends num> {}
588 expect(true, C_T, Object_); 603 expect(true, C_T, Object_);
589 expect(true, C_T, num_); 604 expect(true, C_T, num_);
590 expect(false, C_T, int_); 605 expect(false, C_T, int_);
591 expect(false, C_T, String_); 606 expect(false, C_T, String_);
592 expect(true, C_T, dynamic_); 607 expect(true, C_T, dynamic_, expectMoreSpecific: false);
593 expect(true, C_T, C_T); 608 expect(true, C_T, C_T);
594 expect(false, C_T, A_T); 609 expect(false, C_T, A_T);
595 610
596 // class D<T extends int> {} 611 // class D<T extends int> {}
597 expect(true, D_T, Object_); 612 expect(true, D_T, Object_);
598 expect(true, D_T, num_); 613 expect(true, D_T, num_);
599 expect(true, D_T, int_); 614 expect(true, D_T, int_);
600 expect(false, D_T, String_); 615 expect(false, D_T, String_);
601 expect(true, D_T, dynamic_); 616 expect(true, D_T, dynamic_, expectMoreSpecific: false);
602 expect(true, D_T, D_T); 617 expect(true, D_T, D_T);
603 expect(false, D_T, A_T); 618 expect(false, D_T, A_T);
604 619
605 // class E<T extends S, S extends num> {} 620 // class E<T extends S, S extends num> {}
606 expect(true, E_T, Object_); 621 expect(true, E_T, Object_);
607 expect(true, E_T, num_); 622 expect(true, E_T, num_);
608 expect(false, E_T, int_); 623 expect(false, E_T, int_);
609 expect(false, E_T, String_); 624 expect(false, E_T, String_);
610 expect(true, E_T, dynamic_); 625 expect(true, E_T, dynamic_, expectMoreSpecific: false);
611 expect(true, E_T, E_T); 626 expect(true, E_T, E_T);
612 expect(true, E_T, E_S); 627 expect(true, E_T, E_S);
613 expect(false, E_T, A_T); 628 expect(false, E_T, A_T);
614 629
615 expect(true, E_S, Object_); 630 expect(true, E_S, Object_);
616 expect(true, E_S, num_); 631 expect(true, E_S, num_);
617 expect(false, E_S, int_); 632 expect(false, E_S, int_);
618 expect(false, E_S, String_); 633 expect(false, E_S, String_);
619 expect(true, E_S, dynamic_); 634 expect(true, E_S, dynamic_, expectMoreSpecific: false);
620 expect(false, E_S, E_T); 635 expect(false, E_S, E_T);
621 expect(true, E_S, E_S); 636 expect(true, E_S, E_S);
622 expect(false, E_S, A_T); 637 expect(false, E_S, A_T);
623 638
624 // class F<T extends num, S extends T> {} 639 // class F<T extends num, S extends T> {}
625 expect(true, F_T, Object_); 640 expect(true, F_T, Object_);
626 expect(true, F_T, num_); 641 expect(true, F_T, num_);
627 expect(false, F_T, int_); 642 expect(false, F_T, int_);
628 expect(false, F_T, String_); 643 expect(false, F_T, String_);
629 expect(true, F_T, dynamic_); 644 expect(true, F_T, dynamic_, expectMoreSpecific: false);
630 expect(false, F_T, F_S); 645 expect(false, F_T, F_S);
631 expect(true, F_T, F_T); 646 expect(true, F_T, F_T);
632 expect(false, F_T, A_T); 647 expect(false, F_T, A_T);
633 648
634 expect(true, F_S, Object_); 649 expect(true, F_S, Object_);
635 expect(true, F_S, num_); 650 expect(true, F_S, num_);
636 expect(false, F_S, int_); 651 expect(false, F_S, int_);
637 expect(false, F_S, String_); 652 expect(false, F_S, String_);
638 expect(true, F_S, dynamic_); 653 expect(true, F_S, dynamic_, expectMoreSpecific: false);
639 expect(true, F_S, F_S); 654 expect(true, F_S, F_S);
640 expect(true, F_S, F_T); 655 expect(true, F_S, F_T);
641 expect(false, F_S, A_T); 656 expect(false, F_S, A_T);
642 657
643 // class G<T extends T> {} 658 // class G<T extends T> {}
644 expect(true, G_T, Object_); 659 expect(true, G_T, Object_);
645 expect(false, G_T, num_); 660 expect(false, G_T, num_);
646 expect(false, G_T, int_); 661 expect(false, G_T, int_);
647 expect(false, G_T, String_); 662 expect(false, G_T, String_);
648 expect(true, G_T, dynamic_); 663 expect(true, G_T, dynamic_, expectMoreSpecific: false);
649 expect(true, G_T, G_T); 664 expect(true, G_T, G_T);
650 expect(false, G_T, A_T); 665 expect(false, G_T, A_T);
651 666
652 // class H<T extends S, S extends T> {} 667 // class H<T extends S, S extends T> {}
653 expect(true, H_T, Object_); 668 expect(true, H_T, Object_);
654 expect(false, H_T, num_); 669 expect(false, H_T, num_);
655 expect(false, H_T, int_); 670 expect(false, H_T, int_);
656 expect(false, H_T, String_); 671 expect(false, H_T, String_);
657 expect(true, H_T, dynamic_); 672 expect(true, H_T, dynamic_, expectMoreSpecific: false);
658 expect(true, H_T, H_T); 673 expect(true, H_T, H_T);
659 expect(true, H_T, H_S); 674 expect(true, H_T, H_S);
660 expect(false, H_T, A_T); 675 expect(false, H_T, A_T);
661 676
662 expect(true, H_S, Object_); 677 expect(true, H_S, Object_);
663 expect(false, H_S, num_); 678 expect(false, H_S, num_);
664 expect(false, H_S, int_); 679 expect(false, H_S, int_);
665 expect(false, H_S, String_); 680 expect(false, H_S, String_);
666 expect(true, H_S, dynamic_); 681 expect(true, H_S, dynamic_, expectMoreSpecific: false);
667 expect(true, H_S, H_T); 682 expect(true, H_S, H_T);
668 expect(true, H_S, H_S); 683 expect(true, H_S, H_S);
669 expect(false, H_S, A_T); 684 expect(false, H_S, A_T);
670 685
671 // class I<T extends S, S extends U, U extends T> {} 686 // class I<T extends S, S extends U, U extends T> {}
672 expect(true, I_T, Object_); 687 expect(true, I_T, Object_);
673 expect(false, I_T, num_); 688 expect(false, I_T, num_);
674 expect(false, I_T, int_); 689 expect(false, I_T, int_);
675 expect(false, I_T, String_); 690 expect(false, I_T, String_);
676 expect(true, I_T, dynamic_); 691 expect(true, I_T, dynamic_, expectMoreSpecific: false);
677 expect(true, I_T, I_T); 692 expect(true, I_T, I_T);
678 expect(true, I_T, I_S); 693 expect(true, I_T, I_S);
679 expect(true, I_T, I_U); 694 expect(true, I_T, I_U);
680 expect(false, I_T, A_T); 695 expect(false, I_T, A_T);
681 696
682 expect(true, I_S, Object_); 697 expect(true, I_S, Object_);
683 expect(false, I_S, num_); 698 expect(false, I_S, num_);
684 expect(false, I_S, int_); 699 expect(false, I_S, int_);
685 expect(false, I_S, String_); 700 expect(false, I_S, String_);
686 expect(true, I_S, dynamic_); 701 expect(true, I_S, dynamic_, expectMoreSpecific: false);
687 expect(true, I_S, I_T); 702 expect(true, I_S, I_T);
688 expect(true, I_S, I_S); 703 expect(true, I_S, I_S);
689 expect(true, I_S, I_U); 704 expect(true, I_S, I_U);
690 expect(false, I_S, A_T); 705 expect(false, I_S, A_T);
691 706
692 expect(true, I_U, Object_); 707 expect(true, I_U, Object_);
693 expect(false, I_U, num_); 708 expect(false, I_U, num_);
694 expect(false, I_U, int_); 709 expect(false, I_U, int_);
695 expect(false, I_U, String_); 710 expect(false, I_U, String_);
696 expect(true, I_U, dynamic_); 711 expect(true, I_U, dynamic_, expectMoreSpecific: false);
697 expect(true, I_U, I_T); 712 expect(true, I_U, I_T);
698 expect(true, I_U, I_S); 713 expect(true, I_U, I_S);
699 expect(true, I_U, I_U); 714 expect(true, I_U, I_U);
700 expect(false, I_U, A_T); 715 expect(false, I_U, A_T);
701 716
702 // class J<T extends S, S extends U, U extends S> {} 717 // class J<T extends S, S extends U, U extends S> {}
703 expect(true, J_T, Object_); 718 expect(true, J_T, Object_);
704 expect(false, J_T, num_); 719 expect(false, J_T, num_);
705 expect(false, J_T, int_); 720 expect(false, J_T, int_);
706 expect(false, J_T, String_); 721 expect(false, J_T, String_);
707 expect(true, J_T, dynamic_); 722 expect(true, J_T, dynamic_, expectMoreSpecific: false);
708 expect(true, J_T, J_T); 723 expect(true, J_T, J_T);
709 expect(true, J_T, J_S); 724 expect(true, J_T, J_S);
710 expect(true, J_T, J_U); 725 expect(true, J_T, J_U);
711 expect(false, J_T, A_T); 726 expect(false, J_T, A_T);
712 727
713 expect(true, J_S, Object_); 728 expect(true, J_S, Object_);
714 expect(false, J_S, num_); 729 expect(false, J_S, num_);
715 expect(false, J_S, int_); 730 expect(false, J_S, int_);
716 expect(false, J_S, String_); 731 expect(false, J_S, String_);
717 expect(true, J_S, dynamic_); 732 expect(true, J_S, dynamic_, expectMoreSpecific: false);
718 expect(false, J_S, J_T); 733 expect(false, J_S, J_T);
719 expect(true, J_S, J_S); 734 expect(true, J_S, J_S);
720 expect(true, J_S, J_U); 735 expect(true, J_S, J_U);
721 expect(false, J_S, A_T); 736 expect(false, J_S, A_T);
722 737
723 expect(true, J_U, Object_); 738 expect(true, J_U, Object_);
724 expect(false, J_U, num_); 739 expect(false, J_U, num_);
725 expect(false, J_U, int_); 740 expect(false, J_U, int_);
726 expect(false, J_U, String_); 741 expect(false, J_U, String_);
727 expect(true, J_U, dynamic_); 742 expect(true, J_U, dynamic_, expectMoreSpecific: false);
728 expect(false, J_U, J_T); 743 expect(false, J_U, J_T);
729 expect(true, J_U, J_S); 744 expect(true, J_U, J_S);
730 expect(true, J_U, J_U); 745 expect(true, J_U, J_U);
731 expect(false, J_U, A_T); 746 expect(false, J_U, A_T);
732 })); 747 }));
733 } 748 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/dart_types.dart ('k') | tests/compiler/dart2js/type_test_helper.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698