| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 part of resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 abstract class TreeElements { | 7 abstract class TreeElements { |
| 8 Element get currentElement; | 8 Element get currentElement; |
| 9 Setlet<Node> get superUses; | 9 Setlet<Node> get superUses; |
| 10 | 10 |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 * Warning: do not call this method directly. It should only be | 668 * Warning: do not call this method directly. It should only be |
| 669 * called by [resolveClass] and [ClassSupertypeResolver]. | 669 * called by [resolveClass] and [ClassSupertypeResolver]. |
| 670 */ | 670 */ |
| 671 void loadSupertypes(BaseClassElementX cls, Spannable from) { | 671 void loadSupertypes(BaseClassElementX cls, Spannable from) { |
| 672 compiler.withCurrentElement(cls, () => measure(() { | 672 compiler.withCurrentElement(cls, () => measure(() { |
| 673 if (cls.supertypeLoadState == STATE_DONE) return; | 673 if (cls.supertypeLoadState == STATE_DONE) return; |
| 674 if (cls.supertypeLoadState == STATE_STARTED) { | 674 if (cls.supertypeLoadState == STATE_STARTED) { |
| 675 compiler.reportError(from, MessageKind.CYCLIC_CLASS_HIERARCHY, | 675 compiler.reportError(from, MessageKind.CYCLIC_CLASS_HIERARCHY, |
| 676 {'className': cls.name}); | 676 {'className': cls.name}); |
| 677 cls.supertypeLoadState = STATE_DONE; | 677 cls.supertypeLoadState = STATE_DONE; |
| 678 cls.hasIncompleteHierarchy = true; | |
| 679 cls.allSupertypesAndSelf = | 678 cls.allSupertypesAndSelf = |
| 680 compiler.objectClass.allSupertypesAndSelf.extendClass( | 679 compiler.objectClass.allSupertypesAndSelf.extendClass( |
| 681 cls.computeType(compiler)); | 680 cls.computeType(compiler)); |
| 682 cls.supertype = cls.allSupertypes.head; | 681 cls.supertype = cls.allSupertypes.head; |
| 683 assert(invariant(from, cls.supertype != null, | 682 assert(invariant(from, cls.supertype != null, |
| 684 message: 'Missing supertype on cyclic class $cls.')); | 683 message: 'Missing supertype on cyclic class $cls.')); |
| 685 cls.interfaces = const Link<DartType>(); | |
| 686 return; | 684 return; |
| 687 } | 685 } |
| 688 cls.supertypeLoadState = STATE_STARTED; | 686 cls.supertypeLoadState = STATE_STARTED; |
| 689 compiler.withCurrentElement(cls, () { | 687 compiler.withCurrentElement(cls, () { |
| 690 // TODO(ahe): Cache the node in cls. | 688 // TODO(ahe): Cache the node in cls. |
| 691 cls.parseNode(compiler).accept( | 689 cls.parseNode(compiler).accept( |
| 692 new ClassSupertypeResolver(compiler, cls)); | 690 new ClassSupertypeResolver(compiler, cls)); |
| 693 if (cls.supertypeLoadState != STATE_DONE) { | 691 if (cls.supertypeLoadState != STATE_DONE) { |
| 694 cls.supertypeLoadState = STATE_DONE; | 692 cls.supertypeLoadState = STATE_DONE; |
| 695 } | 693 } |
| 696 }); | 694 }); |
| 697 })); | 695 })); |
| 698 } | 696 } |
| 699 | 697 |
| 700 // TODO(johnniwinther): Remove this queue when resolution has been split into | 698 // TODO(johnniwinther): Remove this queue when resolution has been split into |
| 701 // syntax and semantic resolution. | 699 // syntax and semantic resolution. |
| 702 TypeDeclarationElement currentlyResolvedTypeDeclaration; | 700 ClassElement currentlyResolvedClass; |
| 703 Queue<ClassElement> pendingClassesToBeResolved = new Queue<ClassElement>(); | 701 Queue<ClassElement> pendingClassesToBeResolved = new Queue<ClassElement>(); |
| 704 Queue<ClassElement> pendingClassesToBePostProcessed = | |
| 705 new Queue<ClassElement>(); | |
| 706 | |
| 707 /// Resolve [element] using [resolveTypeDeclaration]. | |
| 708 /// | |
| 709 /// This methods ensure that class declarations encountered through type | |
| 710 /// annotations during the resolution of [element] are resolved after | |
| 711 /// [element] has been resolved. | |
| 712 // TODO(johnniwinther): Encapsulate this functionality in a | |
| 713 // 'TypeDeclarationResolver'. | |
| 714 void _resolveTypeDeclaration(TypeDeclarationElement element, | |
| 715 resolveTypeDeclaration()) { | |
| 716 TypeDeclarationElement previousResolvedTypeDeclaration = | |
| 717 currentlyResolvedTypeDeclaration; | |
| 718 currentlyResolvedTypeDeclaration = element; | |
| 719 resolveTypeDeclaration(); | |
| 720 if (previousResolvedTypeDeclaration == null) { | |
| 721 do { | |
| 722 while (!pendingClassesToBeResolved.isEmpty) { | |
| 723 pendingClassesToBeResolved.removeFirst().ensureResolved(compiler); | |
| 724 } | |
| 725 while (!pendingClassesToBePostProcessed.isEmpty) { | |
| 726 _postProcessClassElement( | |
| 727 pendingClassesToBePostProcessed.removeFirst()); | |
| 728 } | |
| 729 } while (!pendingClassesToBeResolved.isEmpty); | |
| 730 assert(pendingClassesToBeResolved.isEmpty); | |
| 731 assert(pendingClassesToBePostProcessed.isEmpty); | |
| 732 } | |
| 733 currentlyResolvedTypeDeclaration = previousResolvedTypeDeclaration; | |
| 734 } | |
| 735 | 702 |
| 736 /** | 703 /** |
| 737 * Resolve the class [element]. | 704 * Resolve the class [element]. |
| 738 * | 705 * |
| 739 * Before calling this method, [element] was constructed by the | 706 * Before calling this method, [element] was constructed by the |
| 740 * scanner and most fields are null or empty. This method fills in | 707 * scanner and most fields are null or empty. This method fills in |
| 741 * these fields and also ensure that the supertypes of [element] are | 708 * these fields and also ensure that the supertypes of [element] are |
| 742 * resolved. | 709 * resolved. |
| 743 * | 710 * |
| 744 * Warning: Do not call this method directly. Instead use | 711 * Warning: Do not call this method directly. Instead use |
| 745 * [:element.ensureResolved(compiler):]. | 712 * [:element.ensureResolved(compiler):]. |
| 746 */ | 713 */ |
| 747 void resolveClass(ClassElement element) { | 714 void resolveClass(ClassElement element) { |
| 748 _resolveTypeDeclaration(element, () { | 715 ClassElement previousResolvedClass = currentlyResolvedClass; |
| 749 // TODO(johnniwinther): Store the mapping in the resolution enqueuer. | 716 currentlyResolvedClass = element; |
| 750 TreeElementMapping mapping = new TreeElementMapping(element); | 717 // TODO(johnniwinther): Store the mapping in the resolution enqueuer. |
| 751 resolveClassInternal(element, mapping); | 718 TreeElementMapping mapping = new TreeElementMapping(element); |
| 752 }); | 719 resolveClassInternal(element, mapping); |
| 720 if (previousResolvedClass == null) { |
| 721 while (!pendingClassesToBeResolved.isEmpty) { |
| 722 pendingClassesToBeResolved.removeFirst().ensureResolved(compiler); |
| 723 } |
| 724 } |
| 725 currentlyResolvedClass = previousResolvedClass; |
| 753 } | 726 } |
| 754 | 727 |
| 755 void _ensureClassWillBeResolved(ClassElement element) { | 728 void _ensureClassWillBeResolved(ClassElement element) { |
| 756 if (currentlyResolvedTypeDeclaration == null) { | 729 if (currentlyResolvedClass == null) { |
| 757 element.ensureResolved(compiler); | 730 element.ensureResolved(compiler); |
| 758 } else { | 731 } else { |
| 759 pendingClassesToBeResolved.add(element); | 732 pendingClassesToBeResolved.add(element); |
| 760 } | 733 } |
| 761 } | 734 } |
| 762 | 735 |
| 763 void resolveClassInternal(BaseClassElementX element, | 736 void resolveClassInternal(BaseClassElementX element, |
| 764 TreeElementMapping mapping) { | 737 TreeElementMapping mapping) { |
| 765 if (!element.isPatch) { | 738 if (!element.isPatch) { |
| 766 compiler.withCurrentElement(element, () => measure(() { | 739 compiler.withCurrentElement(element, () => measure(() { |
| 767 assert(element.resolutionState == STATE_NOT_STARTED); | 740 assert(element.resolutionState == STATE_NOT_STARTED); |
| 768 element.resolutionState = STATE_STARTED; | 741 element.resolutionState = STATE_STARTED; |
| 769 Node tree = element.parseNode(compiler); | 742 Node tree = element.parseNode(compiler); |
| 770 loadSupertypes(element, tree); | 743 loadSupertypes(element, tree); |
| 771 | 744 |
| 772 ClassResolverVisitor visitor = | 745 ClassResolverVisitor visitor = |
| 773 new ClassResolverVisitor(compiler, element, mapping); | 746 new ClassResolverVisitor(compiler, element, mapping); |
| 774 visitor.visit(tree); | 747 visitor.visit(tree); |
| 775 element.resolutionState = STATE_DONE; | 748 element.resolutionState = STATE_DONE; |
| 776 compiler.onClassResolved(element); | 749 compiler.onClassResolved(element); |
| 777 pendingClassesToBePostProcessed.add(element); | |
| 778 })); | 750 })); |
| 779 if (element.isPatched) { | 751 if (element.isPatched) { |
| 780 // Ensure handling patch after origin. | 752 // Ensure handling patch after origin. |
| 781 element.patch.ensureResolved(compiler); | 753 element.patch.ensureResolved(compiler); |
| 782 } | 754 } |
| 783 } else { // Handle patch classes: | 755 } else { // Handle patch classes: |
| 784 element.resolutionState = STATE_STARTED; | 756 element.resolutionState = STATE_STARTED; |
| 785 // Ensure handling origin before patch. | 757 // Ensure handling origin before patch. |
| 786 element.origin.ensureResolved(compiler); | 758 element.origin.ensureResolved(compiler); |
| 787 // Ensure that the type is computed. | 759 // Ensure that the type is computed. |
| 788 element.computeType(compiler); | 760 element.computeType(compiler); |
| 789 // Copy class hiearchy from origin. | 761 // Copy class hiearchy from origin. |
| 790 element.supertype = element.origin.supertype; | 762 element.supertype = element.origin.supertype; |
| 791 element.interfaces = element.origin.interfaces; | 763 element.interfaces = element.origin.interfaces; |
| 792 element.allSupertypesAndSelf = element.origin.allSupertypesAndSelf; | 764 element.allSupertypesAndSelf = element.origin.allSupertypesAndSelf; |
| 793 // Stepwise assignment to ensure invariant. | 765 // Stepwise assignment to ensure invariant. |
| 794 element.supertypeLoadState = STATE_STARTED; | 766 element.supertypeLoadState = STATE_STARTED; |
| 795 element.supertypeLoadState = STATE_DONE; | 767 element.supertypeLoadState = STATE_DONE; |
| 796 element.resolutionState = STATE_DONE; | 768 element.resolutionState = STATE_DONE; |
| 797 // TODO(johnniwinther): Check matching type variables and | 769 // TODO(johnniwinther): Check matching type variables and |
| 798 // empty extends/implements clauses. | 770 // empty extends/implements clauses. |
| 799 } | 771 } |
| 800 } | |
| 801 | |
| 802 void _postProcessClassElement(BaseClassElementX element) { | |
| 803 for (MetadataAnnotation metadata in element.metadata) { | 772 for (MetadataAnnotation metadata in element.metadata) { |
| 804 metadata.ensureResolved(compiler); | 773 metadata.ensureResolved(compiler); |
| 805 if (!element.isProxy && metadata.value == compiler.proxyConstant) { | 774 if (!element.isProxy && metadata.value == compiler.proxyConstant) { |
| 806 element.isProxy = true; | 775 element.isProxy = true; |
| 807 } | 776 } |
| 808 } | 777 } |
| 809 | 778 |
| 810 // Force resolution of metadata on non-instance members since they may be | 779 // Force resolution of metadata on non-instance members since they may be |
| 811 // inspected by the backend while emitting. Metadata on instance members is | 780 // inspected by the backend while emitting. Metadata on instance members is |
| 812 // handled as a result of processing instantiated class members in the | 781 // handled as a result of processing instantiated class members in the |
| 813 // enqueuer. | 782 // enqueuer. |
| 814 // TODO(ahe): Avoid this eager resolution. | 783 // TODO(ahe): Avoid this eager resolution. |
| 815 element.forEachMember((_, Element member) { | 784 element.forEachMember((_, Element member) { |
| 816 if (!member.isInstanceMember()) { | 785 if (!member.isInstanceMember()) { |
| 817 compiler.withCurrentElement(member, () { | 786 compiler.withCurrentElement(member, () { |
| 818 for (MetadataAnnotation metadata in member.metadata) { | 787 for (MetadataAnnotation metadata in member.metadata) { |
| 819 metadata.ensureResolved(compiler); | 788 metadata.ensureResolved(compiler); |
| 820 } | 789 } |
| 821 }); | 790 }); |
| 822 } | 791 } |
| 823 }); | 792 }); |
| 824 | |
| 825 MembersCreator.computeClassMembers(compiler, element); | |
| 826 } | 793 } |
| 827 | 794 |
| 828 void checkClass(ClassElement element) { | 795 void checkClass(ClassElement element) { |
| 829 if (element.isMixinApplication) { | 796 if (element.isMixinApplication) { |
| 830 checkMixinApplication(element); | 797 checkMixinApplication(element); |
| 831 } else { | 798 } else { |
| 832 checkClassMembers(element); | 799 checkClassMembers(element); |
| 833 } | 800 } |
| 834 } | 801 } |
| 835 | 802 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1019 void checkUserDefinableOperator(Element member) { | 986 void checkUserDefinableOperator(Element member) { |
| 1020 FunctionElement function = member.asFunctionElement(); | 987 FunctionElement function = member.asFunctionElement(); |
| 1021 if (function == null) return; | 988 if (function == null) return; |
| 1022 String value = member.name; | 989 String value = member.name; |
| 1023 if (value == null) return; | 990 if (value == null) return; |
| 1024 if (!(isUserDefinableOperator(value) || identical(value, 'unary-'))) return; | 991 if (!(isUserDefinableOperator(value) || identical(value, 'unary-'))) return; |
| 1025 | 992 |
| 1026 bool isMinus = false; | 993 bool isMinus = false; |
| 1027 int requiredParameterCount; | 994 int requiredParameterCount; |
| 1028 MessageKind messageKind; | 995 MessageKind messageKind; |
| 996 FunctionSignature signature = function.computeSignature(compiler); |
| 1029 if (identical(value, 'unary-')) { | 997 if (identical(value, 'unary-')) { |
| 1030 isMinus = true; | 998 isMinus = true; |
| 1031 messageKind = MessageKind.MINUS_OPERATOR_BAD_ARITY; | 999 messageKind = MessageKind.MINUS_OPERATOR_BAD_ARITY; |
| 1032 requiredParameterCount = 0; | 1000 requiredParameterCount = 0; |
| 1033 } else if (isMinusOperator(value)) { | 1001 } else if (isMinusOperator(value)) { |
| 1034 isMinus = true; | 1002 isMinus = true; |
| 1035 messageKind = MessageKind.MINUS_OPERATOR_BAD_ARITY; | 1003 messageKind = MessageKind.MINUS_OPERATOR_BAD_ARITY; |
| 1036 requiredParameterCount = 1; | 1004 requiredParameterCount = 1; |
| 1037 } else if (isUnaryOperator(value)) { | 1005 } else if (isUnaryOperator(value)) { |
| 1038 messageKind = MessageKind.UNARY_OPERATOR_BAD_ARITY; | 1006 messageKind = MessageKind.UNARY_OPERATOR_BAD_ARITY; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1120 | 1088 |
| 1121 reportErrorWithContext(Element errorneousElement, | 1089 reportErrorWithContext(Element errorneousElement, |
| 1122 MessageKind errorMessage, | 1090 MessageKind errorMessage, |
| 1123 Element contextElement, | 1091 Element contextElement, |
| 1124 MessageKind contextMessage) { | 1092 MessageKind contextMessage) { |
| 1125 compiler.reportError( | 1093 compiler.reportError( |
| 1126 errorneousElement, | 1094 errorneousElement, |
| 1127 errorMessage, | 1095 errorMessage, |
| 1128 {'memberName': contextElement.name, | 1096 {'memberName': contextElement.name, |
| 1129 'className': contextElement.getEnclosingClass().name}); | 1097 'className': contextElement.getEnclosingClass().name}); |
| 1130 compiler.reportInfo(contextElement, contextMessage); | 1098 compiler.reportMessage( |
| 1099 compiler.spanFromElement(contextElement), |
| 1100 contextMessage.error(), |
| 1101 Diagnostic.INFO); |
| 1131 } | 1102 } |
| 1132 | 1103 |
| 1133 void checkValidOverride(Element member, Element superMember) { | 1104 void checkValidOverride(Element member, Element superMember) { |
| 1134 if (superMember == null) return; | 1105 if (superMember == null) return; |
| 1135 if (member.modifiers.isStatic()) { | 1106 if (member.modifiers.isStatic()) { |
| 1136 reportErrorWithContext( | 1107 reportErrorWithContext( |
| 1137 member, MessageKind.NO_STATIC_OVERRIDE, | 1108 member, MessageKind.NO_STATIC_OVERRIDE, |
| 1138 superMember, MessageKind.NO_STATIC_OVERRIDE_CONT); | 1109 superMember, MessageKind.NO_STATIC_OVERRIDE_CONT); |
| 1139 } else { | 1110 } else { |
| 1140 FunctionElement superFunction = superMember.asFunctionElement(); | 1111 FunctionElement superFunction = superMember.asFunctionElement(); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1188 } | 1159 } |
| 1189 | 1160 |
| 1190 FunctionSignature resolveFunctionExpression(Element element, | 1161 FunctionSignature resolveFunctionExpression(Element element, |
| 1191 FunctionExpression node) { | 1162 FunctionExpression node) { |
| 1192 return measure(() => SignatureResolver.analyze( | 1163 return measure(() => SignatureResolver.analyze( |
| 1193 compiler, node.parameters, node.returnType, element)); | 1164 compiler, node.parameters, node.returnType, element)); |
| 1194 } | 1165 } |
| 1195 | 1166 |
| 1196 TreeElements resolveTypedef(TypedefElementX element) { | 1167 TreeElements resolveTypedef(TypedefElementX element) { |
| 1197 if (element.isResolved) return element.mapping; | 1168 if (element.isResolved) return element.mapping; |
| 1198 _resolveTypeDeclaration(element, () { | 1169 TreeElementMapping mapping = new TreeElementMapping(element); |
| 1199 TreeElementMapping mapping = new TreeElementMapping(element); | 1170 // TODO(johnniwinther): Store the mapping in the resolution enqueuer. |
| 1200 // TODO(johnniwinther): Store the mapping in the resolution enqueuer. | 1171 element.mapping = mapping; |
| 1201 element.mapping = mapping; | 1172 return compiler.withCurrentElement(element, () { |
| 1202 return compiler.withCurrentElement(element, () { | 1173 return measure(() { |
| 1203 return measure(() { | 1174 Typedef node = |
| 1204 Typedef node = | 1175 compiler.parser.measure(() => element.parseNode(compiler)); |
| 1205 compiler.parser.measure(() => element.parseNode(compiler)); | 1176 TypedefResolverVisitor visitor = |
| 1206 TypedefResolverVisitor visitor = | 1177 new TypedefResolverVisitor(compiler, element, mapping); |
| 1207 new TypedefResolverVisitor(compiler, element, mapping); | 1178 visitor.visit(node); |
| 1208 visitor.visit(node); | |
| 1209 | 1179 |
| 1210 return mapping; | 1180 return mapping; |
| 1211 }); | |
| 1212 }); | 1181 }); |
| 1213 }); | 1182 }); |
| 1214 } | 1183 } |
| 1215 | 1184 |
| 1216 FunctionType computeFunctionType(Element element, | 1185 FunctionType computeFunctionType(Element element, |
| 1217 FunctionSignature signature) { | 1186 FunctionSignature signature) { |
| 1218 var parameterTypes = new LinkBuilder<DartType>(); | 1187 var parameterTypes = new LinkBuilder<DartType>(); |
| 1219 for (Element parameter in signature.requiredParameters) { | 1188 for (Element parameter in signature.requiredParameters) { |
| 1220 parameterTypes.addLast(parameter.computeType(compiler)); | 1189 parameterTypes.addLast(parameter.computeType(compiler)); |
| 1221 } | 1190 } |
| (...skipping 2665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3887 compiler.internalError( | 3856 compiler.internalError( |
| 3888 "Cannot resolve default superclass for $element", | 3857 "Cannot resolve default superclass for $element", |
| 3889 node: node); | 3858 node: node); |
| 3890 } else { | 3859 } else { |
| 3891 superElement.ensureResolved(compiler); | 3860 superElement.ensureResolved(compiler); |
| 3892 } | 3861 } |
| 3893 element.supertype = superElement.computeType(compiler); | 3862 element.supertype = superElement.computeType(compiler); |
| 3894 } | 3863 } |
| 3895 } | 3864 } |
| 3896 | 3865 |
| 3897 if (element.interfaces == null) { | 3866 assert(element.interfaces == null); |
| 3898 element.interfaces = resolveInterfaces(node.interfaces, node.superclass); | 3867 element.interfaces = resolveInterfaces(node.interfaces, node.superclass); |
| 3899 } else { | |
| 3900 assert(invariant(element, element.hasIncompleteHierarchy)); | |
| 3901 } | |
| 3902 calculateAllSupertypes(element); | 3868 calculateAllSupertypes(element); |
| 3903 | 3869 |
| 3904 if (!element.hasConstructor) { | 3870 if (!element.hasConstructor) { |
| 3905 Element superMember = | 3871 Element superMember = |
| 3906 element.superclass.localLookup(''); | 3872 element.superclass.localLookup(''); |
| 3907 if (superMember == null || !superMember.isGenerativeConstructor()) { | 3873 if (superMember == null || !superMember.isGenerativeConstructor()) { |
| 3908 DualKind kind = MessageKind.CANNOT_FIND_CONSTRUCTOR; | 3874 DualKind kind = MessageKind.CANNOT_FIND_CONSTRUCTOR; |
| 3909 Map arguments = {'constructorName': ''}; | 3875 Map arguments = {'constructorName': ''}; |
| 3910 // TODO(ahe): Why is this a compile-time error? Or if it is an error, | 3876 // TODO(ahe): Why is this a compile-time error? Or if it is an error, |
| 3911 // why do we bother to registerThrowNoSuchMethod below? | 3877 // why do we bother to registerThrowNoSuchMethod below? |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3965 } | 3931 } |
| 3966 | 3932 |
| 3967 DartType applyMixin(DartType supertype, DartType mixinType, Node node) { | 3933 DartType applyMixin(DartType supertype, DartType mixinType, Node node) { |
| 3968 String superName = supertype.name; | 3934 String superName = supertype.name; |
| 3969 String mixinName = mixinType.name; | 3935 String mixinName = mixinType.name; |
| 3970 MixinApplicationElementX mixinApplication = new MixinApplicationElementX( | 3936 MixinApplicationElementX mixinApplication = new MixinApplicationElementX( |
| 3971 "${superName}+${mixinName}", | 3937 "${superName}+${mixinName}", |
| 3972 element.getCompilationUnit(), | 3938 element.getCompilationUnit(), |
| 3973 compiler.getNextFreeClassId(), | 3939 compiler.getNextFreeClassId(), |
| 3974 node, | 3940 node, |
| 3975 new Modifiers.withFlags(new NodeList.empty(), Modifiers.FLAG_ABSTRACT)); | 3941 Modifiers.EMPTY); // TODO(kasperl): Should this be abstract? |
| 3976 // Create synthetic type variables for the mixin application. | 3942 // Create synthetic type variables for the mixin application. |
| 3977 LinkBuilder<DartType> typeVariablesBuilder = new LinkBuilder<DartType>(); | 3943 LinkBuilder<DartType> typeVariablesBuilder = new LinkBuilder<DartType>(); |
| 3978 element.typeVariables.forEach((TypeVariableType type) { | 3944 element.typeVariables.forEach((TypeVariableType type) { |
| 3979 TypeVariableElementX typeVariableElement = new TypeVariableElementX( | 3945 TypeVariableElementX typeVariableElement = new TypeVariableElementX( |
| 3980 type.name, mixinApplication, type.element.parseNode(compiler)); | 3946 type.name, mixinApplication, type.element.parseNode(compiler)); |
| 3981 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement); | 3947 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement); |
| 3982 typeVariablesBuilder.addLast(typeVariable); | 3948 typeVariablesBuilder.addLast(typeVariable); |
| 3983 }); | 3949 }); |
| 3984 Link<DartType> typeVariables = typeVariablesBuilder.toLink(); | 3950 Link<DartType> typeVariables = typeVariablesBuilder.toLink(); |
| 3985 // Setup bounds on the synthetic type variables. | 3951 // Setup bounds on the synthetic type variables. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4037 NamedMixinApplication namedMixinApplication = | 4003 NamedMixinApplication namedMixinApplication = |
| 4038 node.asNamedMixinApplication(); | 4004 node.asNamedMixinApplication(); |
| 4039 Link<DartType> interfaces = (namedMixinApplication != null) | 4005 Link<DartType> interfaces = (namedMixinApplication != null) |
| 4040 ? resolveInterfaces(namedMixinApplication.interfaces, | 4006 ? resolveInterfaces(namedMixinApplication.interfaces, |
| 4041 namedMixinApplication.superclass) | 4007 namedMixinApplication.superclass) |
| 4042 : const Link<DartType>(); | 4008 : const Link<DartType>(); |
| 4043 | 4009 |
| 4044 // The class that is the result of a mixin application implements | 4010 // The class that is the result of a mixin application implements |
| 4045 // the interface of the class that was mixed in so always prepend | 4011 // the interface of the class that was mixed in so always prepend |
| 4046 // that to the interface list. | 4012 // that to the interface list. |
| 4047 if (mixinApplication.interfaces == null) { | 4013 |
| 4048 if (mixinType.kind == TypeKind.INTERFACE) { | 4014 interfaces = interfaces.prepend(mixinType); |
| 4049 // Avoid malformed types in the interfaces. | 4015 assert(mixinApplication.interfaces == null); |
| 4050 interfaces = interfaces.prepend(mixinType); | 4016 mixinApplication.interfaces = interfaces; |
| 4051 } | |
| 4052 mixinApplication.interfaces = interfaces; | |
| 4053 } else { | |
| 4054 assert(invariant(mixinApplication, | |
| 4055 mixinApplication.hasIncompleteHierarchy)); | |
| 4056 } | |
| 4057 | 4017 |
| 4058 ClassElement superclass = supertype.element; | 4018 ClassElement superclass = supertype.element; |
| 4059 if (mixinType.kind != TypeKind.INTERFACE) { | 4019 if (mixinType.kind != TypeKind.INTERFACE) { |
| 4060 mixinApplication.hasIncompleteHierarchy = true; | |
| 4061 mixinApplication.allSupertypesAndSelf = superclass.allSupertypesAndSelf; | 4020 mixinApplication.allSupertypesAndSelf = superclass.allSupertypesAndSelf; |
| 4062 return; | 4021 return; |
| 4063 } | 4022 } |
| 4064 | 4023 |
| 4065 assert(mixinApplication.mixinType == null); | 4024 assert(mixinApplication.mixinType == null); |
| 4066 mixinApplication.mixinType = resolveMixinFor(mixinApplication, mixinType); | 4025 mixinApplication.mixinType = resolveMixinFor(mixinApplication, mixinType); |
| 4067 | 4026 |
| 4068 // Create forwarding constructors for constructor defined in the superclass | 4027 // Create forwarding constructors for constructor defined in the superclass |
| 4069 // because they are now hidden by the mixin application. | 4028 // because they are now hidden by the mixin application. |
| 4070 superclass.forEachLocalMember((Element member) { | 4029 superclass.forEachLocalMember((Element member) { |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4818 return finishConstructorReference(visit(expression), | 4777 return finishConstructorReference(visit(expression), |
| 4819 expression, expression); | 4778 expression, expression); |
| 4820 } | 4779 } |
| 4821 } | 4780 } |
| 4822 | 4781 |
| 4823 /// Looks up [name] in [scope] and unwraps the result. | 4782 /// Looks up [name] in [scope] and unwraps the result. |
| 4824 Element lookupInScope(Compiler compiler, Node node, | 4783 Element lookupInScope(Compiler compiler, Node node, |
| 4825 Scope scope, String name) { | 4784 Scope scope, String name) { |
| 4826 return Elements.unwrap(scope.lookup(name), compiler, node); | 4785 return Elements.unwrap(scope.lookup(name), compiler, node); |
| 4827 } | 4786 } |
| OLD | NEW |