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

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

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

Powered by Google App Engine
This is Rietveld 408576698