| 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 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1158 visitor.visit(node); | 1158 visitor.visit(node); |
| 1159 | 1159 |
| 1160 return mapping; | 1160 return mapping; |
| 1161 }); | 1161 }); |
| 1162 }); | 1162 }); |
| 1163 }); | 1163 }); |
| 1164 } | 1164 } |
| 1165 | 1165 |
| 1166 FunctionType computeFunctionType(Element element, | 1166 FunctionType computeFunctionType(Element element, |
| 1167 FunctionSignature signature) { | 1167 FunctionSignature signature) { |
| 1168 var parameterTypes = new LinkBuilder<DartType>(); | 1168 List<DartType> parameterTypes = <DartType>[]; |
| 1169 for (Element parameter in signature.requiredParameters) { | 1169 for (Element parameter in signature.requiredParameters) { |
| 1170 parameterTypes.addLast(parameter.computeType(compiler)); | 1170 parameterTypes.add(parameter.computeType(compiler)); |
| 1171 } | 1171 } |
| 1172 var optionalParameterTypes = const Link<DartType>(); | 1172 List<DartType> optionalParameterTypes = <DartType>[]; |
| 1173 var namedParameters = const Link<String>(); | 1173 List<String> namedParameters = <String>[]; |
| 1174 var namedParameterTypes = const Link<DartType>(); | 1174 List<DartType> namedParameterTypes = <DartType>[]; |
| 1175 if (signature.optionalParametersAreNamed) { | 1175 if (signature.optionalParametersAreNamed) { |
| 1176 var namedParametersBuilder = new LinkBuilder<String>(); | |
| 1177 var namedParameterTypesBuilder = new LinkBuilder<DartType>(); | |
| 1178 for (Element parameter in signature.orderedOptionalParameters) { | 1176 for (Element parameter in signature.orderedOptionalParameters) { |
| 1179 namedParametersBuilder.addLast(parameter.name); | 1177 namedParameters.add(parameter.name); |
| 1180 namedParameterTypesBuilder.addLast(parameter.computeType(compiler)); | 1178 namedParameterTypes.add(parameter.computeType(compiler)); |
| 1181 } | 1179 } |
| 1182 namedParameters = namedParametersBuilder.toLink(); | |
| 1183 namedParameterTypes = namedParameterTypesBuilder.toLink(); | |
| 1184 } else { | 1180 } else { |
| 1185 var optionalParameterTypesBuilder = new LinkBuilder<DartType>(); | |
| 1186 for (Element parameter in signature.optionalParameters) { | 1181 for (Element parameter in signature.optionalParameters) { |
| 1187 optionalParameterTypesBuilder.addLast(parameter.computeType(compiler)); | 1182 optionalParameterTypes.add(parameter.computeType(compiler)); |
| 1188 } | 1183 } |
| 1189 optionalParameterTypes = optionalParameterTypesBuilder.toLink(); | |
| 1190 } | 1184 } |
| 1191 return new FunctionType(element, | 1185 return new FunctionType(element, |
| 1192 signature.returnType, | 1186 signature.returnType, |
| 1193 parameterTypes.toLink(), | 1187 parameterTypes, |
| 1194 optionalParameterTypes, | 1188 optionalParameterTypes, |
| 1195 namedParameters, | 1189 namedParameters, |
| 1196 namedParameterTypes); | 1190 namedParameterTypes); |
| 1197 } | 1191 } |
| 1198 | 1192 |
| 1199 void resolveMetadataAnnotation(MetadataAnnotationX annotation) { | 1193 void resolveMetadataAnnotation(MetadataAnnotationX annotation) { |
| 1200 compiler.withCurrentElement(annotation.annotatedElement, () => measure(() { | 1194 compiler.withCurrentElement(annotation.annotatedElement, () => measure(() { |
| 1201 assert(annotation.resolutionState == STATE_NOT_STARTED); | 1195 assert(annotation.resolutionState == STATE_NOT_STARTED); |
| 1202 annotation.resolutionState = STATE_STARTED; | 1196 annotation.resolutionState = STATE_STARTED; |
| 1203 | 1197 |
| (...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 visitor.error(node, messageKind, messageArguments); | 1727 visitor.error(node, messageKind, messageArguments); |
| 1734 } else { | 1728 } else { |
| 1735 compiler.backend.registerThrowRuntimeError(visitor.mapping); | 1729 compiler.backend.registerThrowRuntimeError(visitor.mapping); |
| 1736 visitor.warning(node, messageKind, messageArguments); | 1730 visitor.warning(node, messageKind, messageArguments); |
| 1737 } | 1731 } |
| 1738 if (erroneousElement == null) { | 1732 if (erroneousElement == null) { |
| 1739 erroneousElement = new ErroneousElementX( | 1733 erroneousElement = new ErroneousElementX( |
| 1740 messageKind, messageArguments, typeName.source, | 1734 messageKind, messageArguments, typeName.source, |
| 1741 visitor.enclosingElement); | 1735 visitor.enclosingElement); |
| 1742 } | 1736 } |
| 1743 LinkBuilder<DartType> arguments = new LinkBuilder<DartType>(); | 1737 List<DartType> arguments = <DartType>[]; |
| 1744 resolveTypeArguments(visitor, node, null, arguments); | 1738 resolveTypeArguments(visitor, node, null, arguments); |
| 1745 return new MalformedType(erroneousElement, | 1739 return new MalformedType(erroneousElement, |
| 1746 userProvidedBadType, arguments.toLink()); | 1740 userProvidedBadType, arguments); |
| 1747 } | 1741 } |
| 1748 | 1742 |
| 1749 DartType checkNoTypeArguments(DartType type) { | 1743 DartType checkNoTypeArguments(DartType type) { |
| 1750 LinkBuilder<DartType> arguments = new LinkBuilder<DartType>(); | 1744 List<DartType> arguments = <DartType>[]; |
| 1751 bool hasTypeArgumentMismatch = resolveTypeArguments( | 1745 bool hasTypeArgumentMismatch = resolveTypeArguments( |
| 1752 visitor, node, const Link<DartType>(), arguments); | 1746 visitor, node, <DartType>[], arguments); |
| 1753 if (hasTypeArgumentMismatch) { | 1747 if (hasTypeArgumentMismatch) { |
| 1754 return new MalformedType( | 1748 return new MalformedType( |
| 1755 new ErroneousElementX(MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH, | 1749 new ErroneousElementX(MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH, |
| 1756 {'type': node}, typeName.source, visitor.enclosingElement), | 1750 {'type': node}, typeName.source, visitor.enclosingElement), |
| 1757 type, arguments.toLink()); | 1751 type, arguments); |
| 1758 } | 1752 } |
| 1759 return type; | 1753 return type; |
| 1760 } | 1754 } |
| 1761 | 1755 |
| 1762 // Try to construct the type from the element. | 1756 // Try to construct the type from the element. |
| 1763 DartType type; | 1757 DartType type; |
| 1764 if (element == null) { | 1758 if (element == null) { |
| 1765 type = reportFailureAndCreateType( | 1759 type = reportFailureAndCreateType( |
| 1766 MessageKind.CANNOT_RESOLVE_TYPE, {'typeName': node.typeName}); | 1760 MessageKind.CANNOT_RESOLVE_TYPE, {'typeName': node.typeName}); |
| 1767 } else if (element.isAmbiguous()) { | 1761 } else if (element.isAmbiguous()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1779 MessageKind.NOT_A_TYPE, {'node': node.typeName}); | 1773 MessageKind.NOT_A_TYPE, {'node': node.typeName}); |
| 1780 } else { | 1774 } else { |
| 1781 bool addTypeVariableBoundsCheck = false; | 1775 bool addTypeVariableBoundsCheck = false; |
| 1782 if (identical(element, compiler.types.voidType.element) || | 1776 if (identical(element, compiler.types.voidType.element) || |
| 1783 identical(element, compiler.dynamicClass)) { | 1777 identical(element, compiler.dynamicClass)) { |
| 1784 type = checkNoTypeArguments(element.computeType(compiler)); | 1778 type = checkNoTypeArguments(element.computeType(compiler)); |
| 1785 } else if (element.isClass()) { | 1779 } else if (element.isClass()) { |
| 1786 ClassElement cls = element; | 1780 ClassElement cls = element; |
| 1787 compiler.resolver._ensureClassWillBeResolved(cls); | 1781 compiler.resolver._ensureClassWillBeResolved(cls); |
| 1788 element.computeType(compiler); | 1782 element.computeType(compiler); |
| 1789 var arguments = new LinkBuilder<DartType>(); | 1783 List<DartType> arguments = <DartType>[]; |
| 1790 bool hasTypeArgumentMismatch = resolveTypeArguments( | 1784 bool hasTypeArgumentMismatch = resolveTypeArguments( |
| 1791 visitor, node, cls.typeVariables, arguments); | 1785 visitor, node, cls.typeVariables, arguments); |
| 1792 if (hasTypeArgumentMismatch) { | 1786 if (hasTypeArgumentMismatch) { |
| 1793 type = new BadInterfaceType(cls.declaration, | 1787 type = new BadInterfaceType(cls.declaration, |
| 1794 new InterfaceType.forUserProvidedBadType(cls.declaration, | 1788 new InterfaceType.forUserProvidedBadType(cls.declaration, |
| 1795 arguments.toLink())); | 1789 arguments)); |
| 1796 } else { | 1790 } else { |
| 1797 if (arguments.isEmpty) { | 1791 if (arguments.isEmpty) { |
| 1798 type = cls.rawType; | 1792 type = cls.rawType; |
| 1799 } else { | 1793 } else { |
| 1800 type = new InterfaceType(cls.declaration, arguments.toLink()); | 1794 type = new InterfaceType(cls.declaration, arguments); |
| 1801 addTypeVariableBoundsCheck = true; | 1795 addTypeVariableBoundsCheck = true; |
| 1802 } | 1796 } |
| 1803 } | 1797 } |
| 1804 } else if (element.isTypedef()) { | 1798 } else if (element.isTypedef()) { |
| 1805 TypedefElement typdef = element; | 1799 TypedefElement typdef = element; |
| 1806 // TODO(ahe): Should be [ensureResolved]. | 1800 // TODO(ahe): Should be [ensureResolved]. |
| 1807 compiler.resolveTypedef(typdef); | 1801 compiler.resolveTypedef(typdef); |
| 1808 var arguments = new LinkBuilder<DartType>(); | 1802 List<DartType> arguments = <DartType>[]; |
| 1809 bool hasTypeArgumentMismatch = resolveTypeArguments( | 1803 bool hasTypeArgumentMismatch = resolveTypeArguments( |
| 1810 visitor, node, typdef.typeVariables, arguments); | 1804 visitor, node, typdef.typeVariables, arguments); |
| 1811 if (hasTypeArgumentMismatch) { | 1805 if (hasTypeArgumentMismatch) { |
| 1812 type = new BadTypedefType(typdef, | 1806 type = new BadTypedefType(typdef, |
| 1813 new TypedefType.forUserProvidedBadType(typdef, | 1807 new TypedefType.forUserProvidedBadType(typdef, arguments)); |
| 1814 arguments.toLink())); | |
| 1815 } else { | 1808 } else { |
| 1816 if (arguments.isEmpty) { | 1809 if (arguments.isEmpty) { |
| 1817 type = typdef.rawType; | 1810 type = typdef.rawType; |
| 1818 } else { | 1811 } else { |
| 1819 type = new TypedefType(typdef, arguments.toLink()); | 1812 type = new TypedefType(typdef, arguments); |
| 1820 addTypeVariableBoundsCheck = true; | 1813 addTypeVariableBoundsCheck = true; |
| 1821 } | 1814 } |
| 1822 } | 1815 } |
| 1823 } else if (element.isTypeVariable()) { | 1816 } else if (element.isTypeVariable()) { |
| 1824 Element outer = | 1817 Element outer = |
| 1825 visitor.enclosingElement.getOutermostEnclosingMemberOrTopLevel(); | 1818 visitor.enclosingElement.getOutermostEnclosingMemberOrTopLevel(); |
| 1826 bool isInFactoryConstructor = | 1819 bool isInFactoryConstructor = |
| 1827 outer != null && outer.isFactoryConstructor(); | 1820 outer != null && outer.isFactoryConstructor(); |
| 1828 if (!outer.isClass() && | 1821 if (!outer.isClass() && |
| 1829 !outer.isTypedef() && | 1822 !outer.isTypedef() && |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1875 | 1868 |
| 1876 compiler.types.checkTypeVariableBounds(type, checkTypeVariableBound); | 1869 compiler.types.checkTypeVariableBounds(type, checkTypeVariableBound); |
| 1877 } | 1870 } |
| 1878 | 1871 |
| 1879 /** | 1872 /** |
| 1880 * Resolves the type arguments of [node] and adds these to [arguments]. | 1873 * Resolves the type arguments of [node] and adds these to [arguments]. |
| 1881 * | 1874 * |
| 1882 * Returns [: true :] if the number of type arguments did not match the | 1875 * Returns [: true :] if the number of type arguments did not match the |
| 1883 * number of type variables. | 1876 * number of type variables. |
| 1884 */ | 1877 */ |
| 1885 bool resolveTypeArguments( | 1878 bool resolveTypeArguments(MappingVisitor visitor, |
| 1886 MappingVisitor visitor, | 1879 TypeAnnotation node, |
| 1887 TypeAnnotation node, | 1880 List<DartType> typeVariables, |
| 1888 Link<DartType> typeVariables, | 1881 List<DartType> arguments) { |
| 1889 LinkBuilder<DartType> arguments) { | |
| 1890 if (node.typeArguments == null) { | 1882 if (node.typeArguments == null) { |
| 1891 return false; | 1883 return false; |
| 1892 } | 1884 } |
| 1885 int expectedVariables = |
| 1886 typeVariables != null ? typeVariables.length : arguments.length; |
| 1887 int index = 0; |
| 1893 bool typeArgumentCountMismatch = false; | 1888 bool typeArgumentCountMismatch = false; |
| 1894 for (Link<Node> typeArguments = node.typeArguments.nodes; | 1889 for (Link<Node> typeArguments = node.typeArguments.nodes; |
| 1895 !typeArguments.isEmpty; | 1890 !typeArguments.isEmpty; |
| 1896 typeArguments = typeArguments.tail) { | 1891 typeArguments = typeArguments.tail, index++) { |
| 1897 if (typeVariables != null && typeVariables.isEmpty) { | 1892 if (index > expectedVariables - 1) { |
| 1898 visitor.warning( | 1893 visitor.warning( |
| 1899 typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); | 1894 typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); |
| 1900 typeArgumentCountMismatch = true; | 1895 typeArgumentCountMismatch = true; |
| 1901 } | 1896 } |
| 1902 DartType argType = resolveTypeAnnotation(visitor, typeArguments.head); | 1897 DartType argType = resolveTypeAnnotation(visitor, typeArguments.head); |
| 1903 arguments.addLast(argType); | 1898 arguments.add(argType); |
| 1904 if (typeVariables != null && !typeVariables.isEmpty) { | |
| 1905 typeVariables = typeVariables.tail; | |
| 1906 } | |
| 1907 } | 1899 } |
| 1908 if (typeVariables != null && !typeVariables.isEmpty) { | 1900 if (index < expectedVariables) { |
| 1909 visitor.warning(node.typeArguments, | 1901 visitor.warning(node.typeArguments, |
| 1910 MessageKind.MISSING_TYPE_ARGUMENT); | 1902 MessageKind.MISSING_TYPE_ARGUMENT); |
| 1911 typeArgumentCountMismatch = true; | 1903 typeArgumentCountMismatch = true; |
| 1912 } | 1904 } |
| 1913 return typeArgumentCountMismatch; | 1905 return typeArgumentCountMismatch; |
| 1914 } | 1906 } |
| 1915 } | 1907 } |
| 1916 | 1908 |
| 1917 /** | 1909 /** |
| 1918 * Common supertype for resolver visitors that record resolutions in a | 1910 * Common supertype for resolver visitors that record resolutions in a |
| (...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3239 resolveTypeAnnotation(nodes.head); | 3231 resolveTypeAnnotation(nodes.head); |
| 3240 } | 3232 } |
| 3241 } | 3233 } |
| 3242 } | 3234 } |
| 3243 DartType listType; | 3235 DartType listType; |
| 3244 if (typeArgument != null) { | 3236 if (typeArgument != null) { |
| 3245 if (node.isConst() && typeArgument.containsTypeVariables) { | 3237 if (node.isConst() && typeArgument.containsTypeVariables) { |
| 3246 compiler.reportError(arguments.nodes.head, | 3238 compiler.reportError(arguments.nodes.head, |
| 3247 MessageKind.TYPE_VARIABLE_IN_CONSTANT); | 3239 MessageKind.TYPE_VARIABLE_IN_CONSTANT); |
| 3248 } | 3240 } |
| 3249 listType = new InterfaceType(compiler.listClass, | 3241 listType = new InterfaceType(compiler.listClass, [typeArgument]); |
| 3250 new Link<DartType>.fromList([typeArgument])); | |
| 3251 } else { | 3242 } else { |
| 3252 compiler.listClass.computeType(compiler); | 3243 compiler.listClass.computeType(compiler); |
| 3253 listType = compiler.listClass.rawType; | 3244 listType = compiler.listClass.rawType; |
| 3254 } | 3245 } |
| 3255 mapping.setType(node, listType); | 3246 mapping.setType(node, listType); |
| 3256 world.registerInstantiatedType(listType, mapping); | 3247 world.registerInstantiatedType(listType, mapping); |
| 3257 compiler.backend.registerRequiredType(listType, enclosingElement); | 3248 compiler.backend.registerRequiredType(listType, enclosingElement); |
| 3258 visit(node.elements); | 3249 visit(node.elements); |
| 3259 if (node.isConst()) { | 3250 if (node.isConst()) { |
| 3260 analyzeConstant(node); | 3251 analyzeConstant(node); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3457 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) { | 3448 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) { |
| 3458 warning(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); | 3449 warning(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); |
| 3459 resolveTypeAnnotation(nodes.head); | 3450 resolveTypeAnnotation(nodes.head); |
| 3460 } | 3451 } |
| 3461 } | 3452 } |
| 3462 } | 3453 } |
| 3463 } | 3454 } |
| 3464 DartType mapType; | 3455 DartType mapType; |
| 3465 if (valueTypeArgument != null) { | 3456 if (valueTypeArgument != null) { |
| 3466 mapType = new InterfaceType(compiler.mapClass, | 3457 mapType = new InterfaceType(compiler.mapClass, |
| 3467 new Link<DartType>.fromList([keyTypeArgument, valueTypeArgument])); | 3458 [keyTypeArgument, valueTypeArgument]); |
| 3468 } else { | 3459 } else { |
| 3469 compiler.mapClass.computeType(compiler); | 3460 compiler.mapClass.computeType(compiler); |
| 3470 mapType = compiler.mapClass.rawType; | 3461 mapType = compiler.mapClass.rawType; |
| 3471 } | 3462 } |
| 3472 if (node.isConst() && mapType.containsTypeVariables) { | 3463 if (node.isConst() && mapType.containsTypeVariables) { |
| 3473 compiler.reportError(arguments, | 3464 compiler.reportError(arguments, |
| 3474 MessageKind.TYPE_VARIABLE_IN_CONSTANT); | 3465 MessageKind.TYPE_VARIABLE_IN_CONSTANT); |
| 3475 } | 3466 } |
| 3476 mapping.setType(node, mapType); | 3467 mapping.setType(node, mapType); |
| 3477 world.registerInstantiatedType(mapType, mapping); | 3468 world.registerInstantiatedType(mapType, mapping); |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3754 TreeElementMapping mapping) | 3745 TreeElementMapping mapping) |
| 3755 : this.enclosingElement = element, | 3746 : this.enclosingElement = element, |
| 3756 scope = Scope.buildEnclosingScope(element), | 3747 scope = Scope.buildEnclosingScope(element), |
| 3757 super(compiler, mapping); | 3748 super(compiler, mapping); |
| 3758 | 3749 |
| 3759 DartType get objectType => compiler.objectClass.rawType; | 3750 DartType get objectType => compiler.objectClass.rawType; |
| 3760 | 3751 |
| 3761 void resolveTypeVariableBounds(NodeList node) { | 3752 void resolveTypeVariableBounds(NodeList node) { |
| 3762 if (node == null) return; | 3753 if (node == null) return; |
| 3763 | 3754 |
| 3764 var nameSet = new Setlet<String>(); | 3755 Setlet<String> nameSet = new Setlet<String>(); |
| 3765 // Resolve the bounds of type variables. | 3756 // Resolve the bounds of type variables. |
| 3766 Link<DartType> typeLink = element.typeVariables; | 3757 Iterator<DartType> types = element.typeVariables.iterator; |
| 3767 Link<Node> nodeLink = node.nodes; | 3758 Link<Node> nodeLink = node.nodes; |
| 3768 while (!nodeLink.isEmpty) { | 3759 while (!nodeLink.isEmpty) { |
| 3769 TypeVariableType typeVariable = typeLink.head; | 3760 types.moveNext(); |
| 3761 TypeVariableType typeVariable = types.current; |
| 3770 String typeName = typeVariable.name; | 3762 String typeName = typeVariable.name; |
| 3771 TypeVariable typeNode = nodeLink.head; | 3763 TypeVariable typeNode = nodeLink.head; |
| 3772 if (nameSet.contains(typeName)) { | 3764 if (nameSet.contains(typeName)) { |
| 3773 error(typeNode, MessageKind.DUPLICATE_TYPE_VARIABLE_NAME, | 3765 error(typeNode, MessageKind.DUPLICATE_TYPE_VARIABLE_NAME, |
| 3774 {'typeVariableName': typeName}); | 3766 {'typeVariableName': typeName}); |
| 3775 } | 3767 } |
| 3776 nameSet.add(typeName); | 3768 nameSet.add(typeName); |
| 3777 | 3769 |
| 3778 TypeVariableElementX variableElement = typeVariable.element; | 3770 TypeVariableElementX variableElement = typeVariable.element; |
| 3779 if (typeNode.bound != null) { | 3771 if (typeNode.bound != null) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3799 } | 3791 } |
| 3800 seenTypeVariables = seenTypeVariables.prepend(element); | 3792 seenTypeVariables = seenTypeVariables.prepend(element); |
| 3801 bound = element.bound; | 3793 bound = element.bound; |
| 3802 } | 3794 } |
| 3803 } | 3795 } |
| 3804 addDeferredAction(element, checkTypeVariableBound); | 3796 addDeferredAction(element, checkTypeVariableBound); |
| 3805 } else { | 3797 } else { |
| 3806 variableElement.boundCache = objectType; | 3798 variableElement.boundCache = objectType; |
| 3807 } | 3799 } |
| 3808 nodeLink = nodeLink.tail; | 3800 nodeLink = nodeLink.tail; |
| 3809 typeLink = typeLink.tail; | |
| 3810 } | 3801 } |
| 3811 assert(typeLink.isEmpty); | 3802 assert(!types.moveNext()); |
| 3812 } | 3803 } |
| 3813 } | 3804 } |
| 3814 | 3805 |
| 3815 class TypedefResolverVisitor extends TypeDefinitionVisitor { | 3806 class TypedefResolverVisitor extends TypeDefinitionVisitor { |
| 3816 TypedefElement get element => enclosingElement; | 3807 TypedefElement get element => enclosingElement; |
| 3817 | 3808 |
| 3818 TypedefResolverVisitor(Compiler compiler, | 3809 TypedefResolverVisitor(Compiler compiler, |
| 3819 TypedefElement typedefElement, | 3810 TypedefElement typedefElement, |
| 3820 TreeElementMapping mapping) | 3811 TreeElementMapping mapping) |
| 3821 : super(compiler, typedefElement, mapping); | 3812 : super(compiler, typedefElement, mapping); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4079 DartType applyMixin(DartType supertype, DartType mixinType, Node node) { | 4070 DartType applyMixin(DartType supertype, DartType mixinType, Node node) { |
| 4080 String superName = supertype.name; | 4071 String superName = supertype.name; |
| 4081 String mixinName = mixinType.name; | 4072 String mixinName = mixinType.name; |
| 4082 MixinApplicationElementX mixinApplication = new MixinApplicationElementX( | 4073 MixinApplicationElementX mixinApplication = new MixinApplicationElementX( |
| 4083 "${superName}+${mixinName}", | 4074 "${superName}+${mixinName}", |
| 4084 element.getCompilationUnit(), | 4075 element.getCompilationUnit(), |
| 4085 compiler.getNextFreeClassId(), | 4076 compiler.getNextFreeClassId(), |
| 4086 node, | 4077 node, |
| 4087 new Modifiers.withFlags(new NodeList.empty(), Modifiers.FLAG_ABSTRACT)); | 4078 new Modifiers.withFlags(new NodeList.empty(), Modifiers.FLAG_ABSTRACT)); |
| 4088 // Create synthetic type variables for the mixin application. | 4079 // Create synthetic type variables for the mixin application. |
| 4089 LinkBuilder<DartType> typeVariablesBuilder = new LinkBuilder<DartType>(); | 4080 List<DartType> typeVariables = <DartType>[]; |
| 4090 element.typeVariables.forEach((TypeVariableType type) { | 4081 element.typeVariables.forEach((TypeVariableType type) { |
| 4091 TypeVariableElementX typeVariableElement = new TypeVariableElementX( | 4082 TypeVariableElementX typeVariableElement = new TypeVariableElementX( |
| 4092 type.name, mixinApplication, type.element.parseNode(compiler)); | 4083 type.name, mixinApplication, type.element.parseNode(compiler)); |
| 4093 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement); | 4084 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement); |
| 4094 typeVariablesBuilder.addLast(typeVariable); | 4085 typeVariables.add(typeVariable); |
| 4095 }); | 4086 }); |
| 4096 Link<DartType> typeVariables = typeVariablesBuilder.toLink(); | |
| 4097 // Setup bounds on the synthetic type variables. | 4087 // Setup bounds on the synthetic type variables. |
| 4098 Link<DartType> link = typeVariables; | 4088 List<DartType> link = typeVariables; |
| 4089 int index = 0; |
| 4099 element.typeVariables.forEach((TypeVariableType type) { | 4090 element.typeVariables.forEach((TypeVariableType type) { |
| 4100 TypeVariableType typeVariable = link.head; | 4091 TypeVariableType typeVariable = typeVariables[index++]; |
| 4101 TypeVariableElementX typeVariableElement = typeVariable.element; | 4092 TypeVariableElementX typeVariableElement = typeVariable.element; |
| 4102 typeVariableElement.typeCache = typeVariable; | 4093 typeVariableElement.typeCache = typeVariable; |
| 4103 typeVariableElement.boundCache = | 4094 typeVariableElement.boundCache = |
| 4104 type.element.bound.subst(typeVariables, element.typeVariables); | 4095 type.element.bound.subst(typeVariables, element.typeVariables); |
| 4105 link = link.tail; | |
| 4106 }); | 4096 }); |
| 4107 // Setup this and raw type for the mixin application. | 4097 // Setup this and raw type for the mixin application. |
| 4108 mixinApplication.computeThisAndRawType(compiler, typeVariables); | 4098 mixinApplication.computeThisAndRawType(compiler, typeVariables); |
| 4109 // Substitute in synthetic type variables in super and mixin types. | 4099 // Substitute in synthetic type variables in super and mixin types. |
| 4110 supertype = supertype.subst(typeVariables, element.typeVariables); | 4100 supertype = supertype.subst(typeVariables, element.typeVariables); |
| 4111 mixinType = mixinType.subst(typeVariables, element.typeVariables); | 4101 mixinType = mixinType.subst(typeVariables, element.typeVariables); |
| 4112 | 4102 |
| 4113 doApplyMixinTo(mixinApplication, supertype, mixinType); | 4103 doApplyMixinTo(mixinApplication, supertype, mixinType); |
| 4114 mixinApplication.resolutionState = STATE_DONE; | 4104 mixinApplication.resolutionState = STATE_DONE; |
| 4115 mixinApplication.supertypeLoadState = STATE_DONE; | 4105 mixinApplication.supertypeLoadState = STATE_DONE; |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4686 TreeElements _treeElements; | 4676 TreeElements _treeElements; |
| 4687 | 4677 |
| 4688 bool get hasTreeElements => _treeElements != null; | 4678 bool get hasTreeElements => _treeElements != null; |
| 4689 | 4679 |
| 4690 TreeElements get treeElements { | 4680 TreeElements get treeElements { |
| 4691 assert(invariant(this, _treeElements !=null, | 4681 assert(invariant(this, _treeElements !=null, |
| 4692 message: "TreeElements have not been computed for $this.")); | 4682 message: "TreeElements have not been computed for $this.")); |
| 4693 return _treeElements; | 4683 return _treeElements; |
| 4694 } | 4684 } |
| 4695 } | 4685 } |
| OLD | NEW |