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

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

Issue 1413613010: Normalize type masks to use the least upper instantiated subclass/type. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix try/poi Created 5 years, 1 month 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
« no previous file with comments | « pkg/compiler/lib/src/world.dart ('k') | tests/compiler/dart2js/mock_libraries.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 members_test; 5 library members_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 'package:compiler/src/dart_types.dart'; 10 import 'package:compiler/src/dart_types.dart';
11 import "package:compiler/src/elements/elements.dart" 11 import "package:compiler/src/elements/elements.dart"
12 show Element, ClassElement, MemberSignature, Name, PublicName, 12 show Element, ClassElement, MemberSignature, Name, PublicName,
13 DeclaredMember, Member; 13 DeclaredMember, Member;
14 import "package:compiler/src/resolution/class_members.dart" 14 import "package:compiler/src/resolution/class_members.dart"
15 show DeclaredMember, ErroneousMember, SyntheticMember; 15 show MembersCreator, DeclaredMember, ErroneousMember, SyntheticMember;
16 16
17 void main() { 17 void main() {
18 testClassMembers(); 18 testClassMembers();
19 testInterfaceMembers(); 19 testInterfaceMembers();
20 testClassVsInterfaceMembers(); 20 testClassVsInterfaceMembers();
21 testMixinMembers(); 21 testMixinMembers();
22 testMixinMembersWithoutImplements(); 22 testMixinMembersWithoutImplements();
23 } 23 }
24 24
25 MemberSignature getMember(InterfaceType cls, String name, 25 MemberSignature getMember(InterfaceType cls, String name,
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 type: int_, functionType: env.functionType(int_, [])); 205 type: int_, functionType: env.functionType(int_, []));
206 checkMember(Object_, 'noSuchMethod', 206 checkMember(Object_, 'noSuchMethod',
207 functionType: env.functionType(dynamic_, [Invocation_])); 207 functionType: env.functionType(dynamic_, [Invocation_]));
208 checkMember(Object_, 'runtimeType', 208 checkMember(Object_, 'runtimeType',
209 isGetter: true, 209 isGetter: true,
210 type: Type_, functionType: env.functionType(Type_, [])); 210 type: Type_, functionType: env.functionType(Type_, []));
211 checkMember(Object_, 'toString', 211 checkMember(Object_, 'toString',
212 functionType: env.functionType(String_, [])); 212 functionType: env.functionType(String_, []));
213 213
214 InterfaceType A = env['A']; 214 InterfaceType A = env['A'];
215 MembersCreator.computeAllClassMembers(env.compiler, A.element);
216
215 checkMemberCount(A, 5 /*inherited*/ + 9 /*non-static declared*/, 217 checkMemberCount(A, 5 /*inherited*/ + 9 /*non-static declared*/,
216 interfaceMembers: true); 218 interfaceMembers: true);
217 checkMemberCount(A, 5 /*inherited*/ + 9 /*non-abstract declared*/ + 219 checkMemberCount(A, 5 /*inherited*/ + 9 /*non-abstract declared*/ +
218 3 /* abstract declared */, 220 3 /* abstract declared */,
219 interfaceMembers: false); 221 interfaceMembers: false);
220 222
221 checkMember(A, '==', inheritedFrom: Object_); 223 checkMember(A, '==', inheritedFrom: Object_);
222 checkMember(A, 'hashCode', inheritedFrom: Object_); 224 checkMember(A, 'hashCode', inheritedFrom: Object_);
223 checkMember(A, 'noSuchMethod', inheritedFrom: Object_); 225 checkMember(A, 'noSuchMethod', inheritedFrom: Object_);
224 checkMember(A, 'runtimeType', inheritedFrom: Object_); 226 checkMember(A, 'runtimeType', inheritedFrom: Object_);
(...skipping 23 matching lines...) Expand all
248 functionType: env.functionType(dynamic_, [dynamic_])); 250 functionType: env.functionType(dynamic_, [dynamic_]));
249 251
250 checkMember(A, 'method', functionType: env.functionType(dynamic_, [])); 252 checkMember(A, 'method', functionType: env.functionType(dynamic_, []));
251 checkMember(A, 'abstractMethod', 253 checkMember(A, 'abstractMethod',
252 functionType: env.functionType(dynamic_, [])); 254 functionType: env.functionType(dynamic_, []));
253 checkMember(A, 'staticMethod', 255 checkMember(A, 'staticMethod',
254 checkType: CHECK_CLASS, 256 checkType: CHECK_CLASS,
255 isStatic: true, functionType: env.functionType(dynamic_, [])); 257 isStatic: true, functionType: env.functionType(dynamic_, []));
256 258
257 ClassElement B = env.getElement('B'); 259 ClassElement B = env.getElement('B');
260 MembersCreator.computeAllClassMembers(env.compiler, B);
258 InterfaceType B_this = B.thisType; 261 InterfaceType B_this = B.thisType;
259 TypeVariableType B_T = B_this.typeArguments.first; 262 TypeVariableType B_T = B_this.typeArguments.first;
260 checkMemberCount(B_this, 4 /*inherited*/ + 4 /*non-static declared*/, 263 checkMemberCount(B_this, 4 /*inherited*/ + 4 /*non-static declared*/,
261 interfaceMembers: true); 264 interfaceMembers: true);
262 checkMemberCount(B_this, 4 /*inherited*/ + 5 /*declared*/, 265 checkMemberCount(B_this, 4 /*inherited*/ + 5 /*declared*/,
263 interfaceMembers: false); 266 interfaceMembers: false);
264 267
265 checkMember(B_this, '==', inheritedFrom: Object_); 268 checkMember(B_this, '==', inheritedFrom: Object_);
266 checkMember(B_this, 'hashCode', inheritedFrom: Object_); 269 checkMember(B_this, 'hashCode', inheritedFrom: Object_);
267 checkMember(B_this, 'noSuchMethod', inheritedFrom: Object_); 270 checkMember(B_this, 'noSuchMethod', inheritedFrom: Object_);
268 checkMember(B_this, 'runtimeType', inheritedFrom: Object_); 271 checkMember(B_this, 'runtimeType', inheritedFrom: Object_);
269 272
270 checkMember(B_this, 'field', isGetter: true, 273 checkMember(B_this, 'field', isGetter: true,
271 type: B_T, functionType: env.functionType(B_T, [])); 274 type: B_T, functionType: env.functionType(B_T, []));
272 checkMember(B_this, 'field', isSetter: true, 275 checkMember(B_this, 'field', isSetter: true,
273 type: B_T, functionType: env.functionType(void_, [B_T])); 276 type: B_T, functionType: env.functionType(void_, [B_T]));
274 checkMember(B_this, 'method', functionType: env.functionType(void_, [B_T])); 277 checkMember(B_this, 'method', functionType: env.functionType(void_, [B_T]));
275 checkMember(B_this, 'staticMethod', 278 checkMember(B_this, 'staticMethod',
276 checkType: CHECK_CLASS, 279 checkType: CHECK_CLASS,
277 isStatic: true, functionType: env.functionType(dynamic_, [])); 280 isStatic: true, functionType: env.functionType(dynamic_, []));
278 checkMember(B_this, 'toString', 281 checkMember(B_this, 'toString',
279 functionType: env.functionType(dynamic_, [], 282 functionType: env.functionType(dynamic_, [],
280 optionalParameters: [B_T])); 283 optionalParameters: [B_T]));
281 284
282 ClassElement C = env.getElement('C'); 285 ClassElement C = env.getElement('C');
286 MembersCreator.computeAllClassMembers(env.compiler, C);
283 InterfaceType C_this = C.thisType; 287 InterfaceType C_this = C.thisType;
284 TypeVariableType C_S = C_this.typeArguments.first; 288 TypeVariableType C_S = C_this.typeArguments.first;
285 checkMemberCount(C_this, 8 /*inherited*/, interfaceMembers: true); 289 checkMemberCount(C_this, 8 /*inherited*/, interfaceMembers: true);
286 checkMemberCount(C_this, 8 /*inherited*/, interfaceMembers: false); 290 checkMemberCount(C_this, 8 /*inherited*/, interfaceMembers: false);
287 InterfaceType B_S = instantiate(B, [C_S]); 291 InterfaceType B_S = instantiate(B, [C_S]);
288 292
289 checkMember(C_this, '==', inheritedFrom: Object_); 293 checkMember(C_this, '==', inheritedFrom: Object_);
290 checkMember(C_this, 'hashCode', inheritedFrom: Object_); 294 checkMember(C_this, 'hashCode', inheritedFrom: Object_);
291 checkMember(C_this, 'noSuchMethod', inheritedFrom: Object_); 295 checkMember(C_this, 'noSuchMethod', inheritedFrom: Object_);
292 checkMember(C_this, 'runtimeType', inheritedFrom: Object_); 296 checkMember(C_this, 'runtimeType', inheritedFrom: Object_);
293 297
294 checkMember(C_this, 'field', isGetter: true, 298 checkMember(C_this, 'field', isGetter: true,
295 declarer: B_S, 299 declarer: B_S,
296 type: C_S, functionType: env.functionType(C_S, [])); 300 type: C_S, functionType: env.functionType(C_S, []));
297 checkMember(C_this, 'field', isSetter: true, 301 checkMember(C_this, 'field', isSetter: true,
298 declarer: B_S, 302 declarer: B_S,
299 type: C_S, functionType: env.functionType(void_, [C_S])); 303 type: C_S, functionType: env.functionType(void_, [C_S]));
300 checkMember(C_this, 'method', 304 checkMember(C_this, 'method',
301 declarer: B_S, 305 declarer: B_S,
302 functionType: env.functionType(void_, [C_S])); 306 functionType: env.functionType(void_, [C_S]));
303 checkMember(C_this, 'toString', 307 checkMember(C_this, 'toString',
304 declarer: B_S, 308 declarer: B_S,
305 functionType: env.functionType(dynamic_, [], 309 functionType: env.functionType(dynamic_, [],
306 optionalParameters: [C_S])); 310 optionalParameters: [C_S]));
307 311
308 InterfaceType D = env['D']; 312 InterfaceType D = env['D'];
313 MembersCreator.computeAllClassMembers(env.compiler, D.element);
309 checkMemberCount(D, 8 /*inherited*/, interfaceMembers: true); 314 checkMemberCount(D, 8 /*inherited*/, interfaceMembers: true);
310 checkMemberCount(D, 8 /*inherited*/, interfaceMembers: false); 315 checkMemberCount(D, 8 /*inherited*/, interfaceMembers: false);
311 InterfaceType B_int = instantiate(B, [int_]); 316 InterfaceType B_int = instantiate(B, [int_]);
312 317
313 checkMember(D, '==', inheritedFrom: Object_); 318 checkMember(D, '==', inheritedFrom: Object_);
314 checkMember(D, 'hashCode', inheritedFrom: Object_); 319 checkMember(D, 'hashCode', inheritedFrom: Object_);
315 checkMember(D, 'noSuchMethod', inheritedFrom: Object_); 320 checkMember(D, 'noSuchMethod', inheritedFrom: Object_);
316 checkMember(D, 'runtimeType', inheritedFrom: Object_); 321 checkMember(D, 'runtimeType', inheritedFrom: Object_);
317 322
318 checkMember(D, 'field', isGetter: true, 323 checkMember(D, 'field', isGetter: true,
319 declarer: B_int, 324 declarer: B_int,
320 type: int_, functionType: env.functionType(int_, [])); 325 type: int_, functionType: env.functionType(int_, []));
321 checkMember(D, 'field', isSetter: true, 326 checkMember(D, 'field', isSetter: true,
322 declarer: B_int, 327 declarer: B_int,
323 type: int_, functionType: env.functionType(void_, [int_])); 328 type: int_, functionType: env.functionType(void_, [int_]));
324 checkMember(D, 'method', 329 checkMember(D, 'method',
325 declarer: B_int, 330 declarer: B_int,
326 functionType: env.functionType(void_, [int_])); 331 functionType: env.functionType(void_, [int_]));
327 checkMember(D, 'toString', 332 checkMember(D, 'toString',
328 declarer: B_int, 333 declarer: B_int,
329 functionType: env.functionType(dynamic_, [], 334 functionType: env.functionType(dynamic_, [],
330 optionalParameters: [int_])); 335 optionalParameters: [int_]));
331 336
332 InterfaceType E = env['E']; 337 InterfaceType E = env['E'];
338 MembersCreator.computeAllClassMembers(env.compiler, E.element);
333 checkMemberCount(E, 8 /*inherited*/, interfaceMembers: true); 339 checkMemberCount(E, 8 /*inherited*/, interfaceMembers: true);
334 checkMemberCount(E, 8 /*inherited*/, interfaceMembers: false); 340 checkMemberCount(E, 8 /*inherited*/, interfaceMembers: false);
335 341
336 checkMember(E, '==', inheritedFrom: Object_); 342 checkMember(E, '==', inheritedFrom: Object_);
337 checkMember(E, 'hashCode', inheritedFrom: Object_); 343 checkMember(E, 'hashCode', inheritedFrom: Object_);
338 checkMember(E, 'noSuchMethod', inheritedFrom: Object_); 344 checkMember(E, 'noSuchMethod', inheritedFrom: Object_);
339 checkMember(E, 'runtimeType', inheritedFrom: Object_); 345 checkMember(E, 'runtimeType', inheritedFrom: Object_);
340 346
341 checkMember(E, 'field', isGetter: true, 347 checkMember(E, 'field', isGetter: true,
342 declarer: B_int, 348 declarer: B_int,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 DynamicType dynamic_ = env['dynamic']; 410 DynamicType dynamic_ = env['dynamic'];
405 VoidType void_ = env['void']; 411 VoidType void_ = env['void'];
406 InterfaceType num_ = env['num']; 412 InterfaceType num_ = env['num'];
407 InterfaceType int_ = env['int']; 413 InterfaceType int_ = env['int'];
408 414
409 InterfaceType A = env['A']; 415 InterfaceType A = env['A'];
410 InterfaceType B = env['B']; 416 InterfaceType B = env['B'];
411 InterfaceType C = env['C']; 417 InterfaceType C = env['C'];
412 InterfaceType D = env['D']; 418 InterfaceType D = env['D'];
413 419
420 // Ensure that members have been computed on all classes.
421 MembersCreator.computeAllClassMembers(env.compiler, D.element);
422
414 // A: num method1() 423 // A: num method1()
415 // B: int method1() 424 // B: int method1()
416 // D: dynamic method1() -- synthesized from A and B. 425 // D: dynamic method1() -- synthesized from A and B.
417 checkMember(D, 'method1', 426 checkMember(D, 'method1',
418 synthesizedFrom: [A, B], 427 synthesizedFrom: [A, B],
419 functionType: env.functionType(dynamic_ , []), 428 functionType: env.functionType(dynamic_ , []),
420 checkType: NO_CLASS_MEMBER); 429 checkType: NO_CLASS_MEMBER);
421 430
422 // A: void method2() 431 // A: void method2()
423 // B: int method2() 432 // B: int method2()
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 578
570 DynamicType dynamic_ = env['dynamic']; 579 DynamicType dynamic_ = env['dynamic'];
571 VoidType void_ = env['void']; 580 VoidType void_ = env['void'];
572 InterfaceType num_ = env['num']; 581 InterfaceType num_ = env['num'];
573 InterfaceType int_ = env['int']; 582 InterfaceType int_ = env['int'];
574 583
575 InterfaceType A = env['A']; 584 InterfaceType A = env['A'];
576 InterfaceType B = env['B']; 585 InterfaceType B = env['B'];
577 InterfaceType C = env['C']; 586 InterfaceType C = env['C'];
578 587
588 // Ensure that members have been computed on all classes.
589 MembersCreator.computeAllClassMembers(env.compiler, C.element);
590
579 // A: method1() 591 // A: method1()
580 // B: method1() 592 // B: method1()
581 // C class: method1() -- inherited from A. 593 // C class: method1() -- inherited from A.
582 // C interface: dynamic method1() -- synthesized from A and B. 594 // C interface: dynamic method1() -- synthesized from A and B.
583 MemberSignature interfaceMember = 595 MemberSignature interfaceMember =
584 checkMember(C, 'method1', checkType: CHECK_INTERFACE, 596 checkMember(C, 'method1', checkType: CHECK_INTERFACE,
585 synthesizedFrom: [A, B], 597 synthesizedFrom: [A, B],
586 functionType: env.functionType(dynamic_ , [])); 598 functionType: env.functionType(dynamic_ , []));
587 MemberSignature classMember = 599 MemberSignature classMember =
588 checkMember(C, 'method1', checkType: CHECK_CLASS, inheritedFrom: A); 600 checkMember(C, 'method1', checkType: CHECK_CLASS, inheritedFrom: A);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 639
628 ClassElement A = env.getElement('A'); 640 ClassElement A = env.getElement('A');
629 ClassElement B = env.getElement('B'); 641 ClassElement B = env.getElement('B');
630 ClassElement C = env.getElement('C'); 642 ClassElement C = env.getElement('C');
631 InterfaceType C_this = C.thisType; 643 InterfaceType C_this = C.thisType;
632 TypeVariableType C_U = C_this.typeArguments[0]; 644 TypeVariableType C_U = C_this.typeArguments[0];
633 TypeVariableType C_V = C_this.typeArguments[1]; 645 TypeVariableType C_V = C_this.typeArguments[1];
634 InterfaceType A_U = instantiate(A, [C_U]); 646 InterfaceType A_U = instantiate(A, [C_U]);
635 InterfaceType B_V = instantiate(B, [C_V]); 647 InterfaceType B_V = instantiate(B, [C_V]);
636 648
649 // Ensure that members have been computed on all classes.
650 MembersCreator.computeAllClassMembers(env.compiler, C);
651
637 // A: method1() 652 // A: method1()
638 // B: method1() 653 // B: method1()
639 // C class: method1() -- inherited from A. 654 // C class: method1() -- inherited from A.
640 // C interface: dynamic method1() -- synthesized from A and B. 655 // C interface: dynamic method1() -- synthesized from A and B.
641 MemberSignature interfaceMember = 656 MemberSignature interfaceMember =
642 checkMember(C_this, 'method1', checkType: CHECK_INTERFACE, 657 checkMember(C_this, 'method1', checkType: CHECK_INTERFACE,
643 synthesizedFrom: [A_U, B_V], 658 synthesizedFrom: [A_U, B_V],
644 functionType: env.functionType(dynamic_ , [])); 659 functionType: env.functionType(dynamic_ , []));
645 MemberSignature classMember = 660 MemberSignature classMember =
646 checkMember(C_this, 'method1', checkType: CHECK_CLASS, 661 checkMember(C_this, 'method1', checkType: CHECK_CLASS,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
695 710
696 DynamicType dynamic_ = env['dynamic']; 711 DynamicType dynamic_ = env['dynamic'];
697 VoidType void_ = env['void']; 712 VoidType void_ = env['void'];
698 InterfaceType num_ = env['num']; 713 InterfaceType num_ = env['num'];
699 InterfaceType int_ = env['int']; 714 InterfaceType int_ = env['int'];
700 715
701 InterfaceType A = env['A']; 716 InterfaceType A = env['A'];
702 InterfaceType B = env['B']; 717 InterfaceType B = env['B'];
703 InterfaceType C = env['C']; 718 InterfaceType C = env['C'];
704 719
720 // Ensure that members have been computed on all classes.
721 MembersCreator.computeAllClassMembers(env.compiler, C.element);
722
705 checkMember(C, 'm', checkType: NO_CLASS_MEMBER, 723 checkMember(C, 'm', checkType: NO_CLASS_MEMBER,
706 inheritedFrom: A, 724 inheritedFrom: A,
707 functionType: env.functionType(dynamic_ , [])); 725 functionType: env.functionType(dynamic_ , []));
708 })); 726 }));
709 } 727 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/world.dart ('k') | tests/compiler/dart2js/mock_libraries.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698