OLD | NEW |
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/elements/resolution_types.dart'; | 10 import 'package:compiler/src/elements/resolution_types.dart'; |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 toString([T t]) {} | 187 toString([T t]) {} |
188 } | 188 } |
189 class C<S> extends B<S> {} | 189 class C<S> extends B<S> {} |
190 class D extends C<int> {} | 190 class D extends C<int> {} |
191 class E extends D {} | 191 class E extends D {} |
192 """, | 192 """, |
193 useMockCompiler: false) | 193 useMockCompiler: false) |
194 .then((env) { | 194 .then((env) { |
195 ResolutionInterfaceType bool_ = env['bool']; | 195 ResolutionInterfaceType bool_ = env['bool']; |
196 ResolutionInterfaceType String_ = env['String']; | 196 ResolutionInterfaceType String_ = env['String']; |
197 ResolutionInterfaceType num_ = env['num']; | |
198 ResolutionInterfaceType int_ = env['int']; | 197 ResolutionInterfaceType int_ = env['int']; |
199 ResolutionDynamicType dynamic_ = env['dynamic']; | 198 ResolutionDynamicType dynamic_ = env['dynamic']; |
200 ResolutionVoidType void_ = env['void']; | 199 ResolutionVoidType void_ = env['void']; |
201 ResolutionInterfaceType Type_ = env['Type']; | 200 ResolutionInterfaceType Type_ = env['Type']; |
202 ResolutionInterfaceType Invocation_ = env['Invocation']; | 201 ResolutionInterfaceType Invocation_ = env['Invocation']; |
203 | 202 |
204 ResolutionInterfaceType Object_ = env['Object']; | 203 ResolutionInterfaceType Object_ = env['Object']; |
205 checkMemberCount(Object_, 5 /*declared*/, interfaceMembers: true); | 204 checkMemberCount(Object_, 5 /*declared*/, interfaceMembers: true); |
206 checkMemberCount(Object_, 5 /*declared*/, interfaceMembers: false); | 205 checkMemberCount(Object_, 5 /*declared*/, interfaceMembers: false); |
207 | 206 |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 } | 446 } |
448 abstract class C { | 447 abstract class C { |
449 int method3(); | 448 int method3(); |
450 num method4(); | 449 num method4(); |
451 } | 450 } |
452 abstract class D implements A, B, C {} | 451 abstract class D implements A, B, C {} |
453 """).then((env) { | 452 """).then((env) { |
454 ResolutionDynamicType dynamic_ = env['dynamic']; | 453 ResolutionDynamicType dynamic_ = env['dynamic']; |
455 ResolutionVoidType void_ = env['void']; | 454 ResolutionVoidType void_ = env['void']; |
456 ResolutionInterfaceType num_ = env['num']; | 455 ResolutionInterfaceType num_ = env['num']; |
457 ResolutionInterfaceType int_ = env['int']; | |
458 | 456 |
459 ResolutionInterfaceType A = env['A']; | 457 ResolutionInterfaceType A = env['A']; |
460 ResolutionInterfaceType B = env['B']; | 458 ResolutionInterfaceType B = env['B']; |
461 ResolutionInterfaceType C = env['C']; | 459 ResolutionInterfaceType C = env['C']; |
462 ResolutionInterfaceType D = env['D']; | 460 ResolutionInterfaceType D = env['D']; |
463 | 461 |
464 // Ensure that members have been computed on all classes. | 462 // Ensure that members have been computed on all classes. |
465 MembersCreator.computeAllClassMembers(env.resolution, D.element); | 463 MembersCreator.computeAllClassMembers(env.resolution, D.element); |
466 | 464 |
467 // A: num method1() | 465 // A: num method1() |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
615 method1() {} | 613 method1() {} |
616 method2() {} | 614 method2() {} |
617 } | 615 } |
618 abstract class B { | 616 abstract class B { |
619 method1(); | 617 method1(); |
620 method2(a); | 618 method2(a); |
621 } | 619 } |
622 abstract class C extends A implements B {} | 620 abstract class C extends A implements B {} |
623 """).then((env) { | 621 """).then((env) { |
624 ResolutionDynamicType dynamic_ = env['dynamic']; | 622 ResolutionDynamicType dynamic_ = env['dynamic']; |
625 ResolutionVoidType void_ = env['void']; | |
626 ResolutionInterfaceType num_ = env['num']; | |
627 ResolutionInterfaceType int_ = env['int']; | |
628 | 623 |
629 ResolutionInterfaceType A = env['A']; | 624 ResolutionInterfaceType A = env['A']; |
630 ResolutionInterfaceType B = env['B']; | 625 ResolutionInterfaceType B = env['B']; |
631 ResolutionInterfaceType C = env['C']; | 626 ResolutionInterfaceType C = env['C']; |
632 | 627 |
633 // Ensure that members have been computed on all classes. | 628 // Ensure that members have been computed on all classes. |
634 MembersCreator.computeAllClassMembers(env.resolution, C.element); | 629 MembersCreator.computeAllClassMembers(env.resolution, C.element); |
635 | 630 |
636 // A: method1() | 631 // A: method1() |
637 // B: method1() | 632 // B: method1() |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 method4(T a) {} | 664 method4(T a) {} |
670 } | 665 } |
671 abstract class B<S> { | 666 abstract class B<S> { |
672 method1(); | 667 method1(); |
673 method2(a); | 668 method2(a); |
674 method3(S a) {} | 669 method3(S a) {} |
675 } | 670 } |
676 abstract class C<U, V> extends Object with A<U> implements B<V> {} | 671 abstract class C<U, V> extends Object with A<U> implements B<V> {} |
677 """).then((env) { | 672 """).then((env) { |
678 ResolutionDynamicType dynamic_ = env['dynamic']; | 673 ResolutionDynamicType dynamic_ = env['dynamic']; |
679 ResolutionVoidType void_ = env['void']; | |
680 ResolutionInterfaceType num_ = env['num']; | |
681 ResolutionInterfaceType int_ = env['int']; | |
682 | 674 |
683 ClassElement A = env.getElement('A'); | 675 ClassElement A = env.getElement('A'); |
684 ClassElement B = env.getElement('B'); | 676 ClassElement B = env.getElement('B'); |
685 ClassElement C = env.getElement('C'); | 677 ClassElement C = env.getElement('C'); |
686 ResolutionInterfaceType C_this = C.thisType; | 678 ResolutionInterfaceType C_this = C.thisType; |
687 ResolutionTypeVariableType C_U = C_this.typeArguments[0]; | 679 ResolutionTypeVariableType C_U = C_this.typeArguments[0]; |
688 ResolutionTypeVariableType C_V = C_this.typeArguments[1]; | 680 ResolutionTypeVariableType C_V = C_this.typeArguments[1]; |
689 ResolutionInterfaceType A_U = instantiate(A, [C_U]); | 681 ResolutionInterfaceType A_U = instantiate(A, [C_U]); |
690 ResolutionInterfaceType B_V = instantiate(B, [C_V]); | 682 ResolutionInterfaceType B_V = instantiate(B, [C_V]); |
691 | 683 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 void testMixinMembersWithoutImplements() { | 733 void testMixinMembersWithoutImplements() { |
742 asyncTest(() => TypeEnvironment.create(r""" | 734 asyncTest(() => TypeEnvironment.create(r""" |
743 abstract class A { | 735 abstract class A { |
744 m(); | 736 m(); |
745 } | 737 } |
746 abstract class B implements A { | 738 abstract class B implements A { |
747 } | 739 } |
748 abstract class C extends Object with B {} | 740 abstract class C extends Object with B {} |
749 """).then((env) { | 741 """).then((env) { |
750 ResolutionDynamicType dynamic_ = env['dynamic']; | 742 ResolutionDynamicType dynamic_ = env['dynamic']; |
751 ResolutionVoidType void_ = env['void']; | |
752 ResolutionInterfaceType num_ = env['num']; | |
753 ResolutionInterfaceType int_ = env['int']; | |
754 | 743 |
755 ResolutionInterfaceType A = env['A']; | 744 ResolutionInterfaceType A = env['A']; |
756 ResolutionInterfaceType B = env['B']; | |
757 ResolutionInterfaceType C = env['C']; | 745 ResolutionInterfaceType C = env['C']; |
758 | 746 |
759 // Ensure that members have been computed on all classes. | 747 // Ensure that members have been computed on all classes. |
760 MembersCreator.computeAllClassMembers(env.resolution, C.element); | 748 MembersCreator.computeAllClassMembers(env.resolution, C.element); |
761 | 749 |
762 checkMember(C, 'm', | 750 checkMember(C, 'm', |
763 checkType: NO_CLASS_MEMBER, | 751 checkType: NO_CLASS_MEMBER, |
764 inheritedFrom: A, | 752 inheritedFrom: A, |
765 functionType: env.functionType(dynamic_, [])); | 753 functionType: env.functionType(dynamic_, [])); |
766 })); | 754 })); |
767 } | 755 } |
OLD | NEW |