| 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 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1163 visitor.visit(node); | 1163 visitor.visit(node); |
| 1164 | 1164 |
| 1165 return mapping; | 1165 return mapping; |
| 1166 }); | 1166 }); |
| 1167 }); | 1167 }); |
| 1168 }); | 1168 }); |
| 1169 } | 1169 } |
| 1170 | 1170 |
| 1171 FunctionType computeFunctionType(Element element, | 1171 FunctionType computeFunctionType(Element element, |
| 1172 FunctionSignature signature) { | 1172 FunctionSignature signature) { |
| 1173 var parameterTypes = new LinkBuilder<DartType>(); | 1173 List<DartType> parameterTypes = <DartType>[]; |
| 1174 for (Element parameter in signature.requiredParameters) { | 1174 for (Element parameter in signature.requiredParameters) { |
| 1175 parameterTypes.addLast(parameter.computeType(compiler)); | 1175 parameterTypes.add(parameter.computeType(compiler)); |
| 1176 } | 1176 } |
| 1177 var optionalParameterTypes = const Link<DartType>(); | 1177 List<DartType> optionalParameterTypes = <DartType>[]; |
| 1178 var namedParameters = const Link<String>(); | 1178 List<String> namedParameters = <String>[]; |
| 1179 var namedParameterTypes = const Link<DartType>(); | 1179 List<DartType> namedParameterTypes = <DartType>[]; |
| 1180 if (signature.optionalParametersAreNamed) { | 1180 if (signature.optionalParametersAreNamed) { |
| 1181 var namedParametersBuilder = new LinkBuilder<String>(); | |
| 1182 var namedParameterTypesBuilder = new LinkBuilder<DartType>(); | |
| 1183 for (Element parameter in signature.orderedOptionalParameters) { | 1181 for (Element parameter in signature.orderedOptionalParameters) { |
| 1184 namedParametersBuilder.addLast(parameter.name); | 1182 namedParameters.add(parameter.name); |
| 1185 namedParameterTypesBuilder.addLast(parameter.computeType(compiler)); | 1183 namedParameterTypes.add(parameter.computeType(compiler)); |
| 1186 } | 1184 } |
| 1187 namedParameters = namedParametersBuilder.toLink(); | |
| 1188 namedParameterTypes = namedParameterTypesBuilder.toLink(); | |
| 1189 } else { | 1185 } else { |
| 1190 var optionalParameterTypesBuilder = new LinkBuilder<DartType>(); | |
| 1191 for (Element parameter in signature.optionalParameters) { | 1186 for (Element parameter in signature.optionalParameters) { |
| 1192 optionalParameterTypesBuilder.addLast(parameter.computeType(compiler)); | 1187 optionalParameterTypes.add(parameter.computeType(compiler)); |
| 1193 } | 1188 } |
| 1194 optionalParameterTypes = optionalParameterTypesBuilder.toLink(); | |
| 1195 } | 1189 } |
| 1196 return new FunctionType(element, | 1190 return new FunctionType(element, |
| 1197 signature.returnType, | 1191 signature.returnType, |
| 1198 parameterTypes.toLink(), | 1192 parameterTypes, |
| 1199 optionalParameterTypes, | 1193 optionalParameterTypes, |
| 1200 namedParameters, | 1194 namedParameters, |
| 1201 namedParameterTypes); | 1195 namedParameterTypes); |
| 1202 } | 1196 } |
| 1203 | 1197 |
| 1204 void resolveMetadataAnnotation(MetadataAnnotationX annotation) { | 1198 void resolveMetadataAnnotation(MetadataAnnotationX annotation) { |
| 1205 compiler.withCurrentElement(annotation.annotatedElement, () => measure(() { | 1199 compiler.withCurrentElement(annotation.annotatedElement, () => measure(() { |
| 1206 assert(annotation.resolutionState == STATE_NOT_STARTED); | 1200 assert(annotation.resolutionState == STATE_NOT_STARTED); |
| 1207 annotation.resolutionState = STATE_STARTED; | 1201 annotation.resolutionState = STATE_STARTED; |
| 1208 | 1202 |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 {DartType userProvidedBadType}) { | 1706 {DartType userProvidedBadType}) { |
| 1713 if (malformedIsError) { | 1707 if (malformedIsError) { |
| 1714 visitor.error(node, messageKind, messageArguments); | 1708 visitor.error(node, messageKind, messageArguments); |
| 1715 } else { | 1709 } else { |
| 1716 compiler.backend.registerThrowRuntimeError(visitor.mapping); | 1710 compiler.backend.registerThrowRuntimeError(visitor.mapping); |
| 1717 visitor.warning(node, messageKind, messageArguments); | 1711 visitor.warning(node, messageKind, messageArguments); |
| 1718 } | 1712 } |
| 1719 Element erroneousElement = new ErroneousElementX( | 1713 Element erroneousElement = new ErroneousElementX( |
| 1720 messageKind, messageArguments, typeName.source, | 1714 messageKind, messageArguments, typeName.source, |
| 1721 visitor.enclosingElement); | 1715 visitor.enclosingElement); |
| 1722 LinkBuilder<DartType> arguments = new LinkBuilder<DartType>(); | 1716 List<DartType> arguments = <DartType>[]; |
| 1723 resolveTypeArguments(visitor, node, null, arguments); | 1717 resolveTypeArguments(visitor, node, null, arguments); |
| 1724 return new MalformedType(erroneousElement, | 1718 return new MalformedType(erroneousElement, |
| 1725 userProvidedBadType, arguments.toLink()); | 1719 userProvidedBadType, arguments); |
| 1726 } | 1720 } |
| 1727 | 1721 |
| 1728 DartType checkNoTypeArguments(DartType type) { | 1722 DartType checkNoTypeArguments(DartType type) { |
| 1729 LinkBuilder<DartType> arguments = new LinkBuilder<DartType>(); | 1723 List<DartType> arguments = <DartType>[]; |
| 1730 bool hasTypeArgumentMismatch = resolveTypeArguments( | 1724 bool hasTypeArgumentMismatch = resolveTypeArguments( |
| 1731 visitor, node, const Link<DartType>(), arguments); | 1725 visitor, node, <DartType>[], arguments); |
| 1732 if (hasTypeArgumentMismatch) { | 1726 if (hasTypeArgumentMismatch) { |
| 1733 return new MalformedType( | 1727 return new MalformedType( |
| 1734 new ErroneousElementX(MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH, | 1728 new ErroneousElementX(MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH, |
| 1735 {'type': node}, typeName.source, visitor.enclosingElement), | 1729 {'type': node}, typeName.source, visitor.enclosingElement), |
| 1736 type, arguments.toLink()); | 1730 type, arguments); |
| 1737 } | 1731 } |
| 1738 return type; | 1732 return type; |
| 1739 } | 1733 } |
| 1740 | 1734 |
| 1741 DartType type; | 1735 DartType type; |
| 1742 if (element == null) { | 1736 if (element == null) { |
| 1743 type = reportFailureAndCreateType( | 1737 type = reportFailureAndCreateType( |
| 1744 MessageKind.CANNOT_RESOLVE_TYPE, {'typeName': node.typeName}); | 1738 MessageKind.CANNOT_RESOLVE_TYPE, {'typeName': node.typeName}); |
| 1745 } else if (element.isAmbiguous()) { | 1739 } else if (element.isAmbiguous()) { |
| 1746 AmbiguousElement ambiguous = element; | 1740 AmbiguousElement ambiguous = element; |
| 1747 type = reportFailureAndCreateType( | 1741 type = reportFailureAndCreateType( |
| 1748 ambiguous.messageKind, ambiguous.messageArguments); | 1742 ambiguous.messageKind, ambiguous.messageArguments); |
| 1749 ambiguous.diagnose(visitor.mapping.currentElement, compiler); | 1743 ambiguous.diagnose(visitor.mapping.currentElement, compiler); |
| 1750 } else if (!element.impliesType()) { | 1744 } else if (!element.impliesType()) { |
| 1751 type = reportFailureAndCreateType( | 1745 type = reportFailureAndCreateType( |
| 1752 MessageKind.NOT_A_TYPE, {'node': node.typeName}); | 1746 MessageKind.NOT_A_TYPE, {'node': node.typeName}); |
| 1753 } else { | 1747 } else { |
| 1754 bool addTypeVariableBoundsCheck = false; | 1748 bool addTypeVariableBoundsCheck = false; |
| 1755 if (identical(element, compiler.types.voidType.element) || | 1749 if (identical(element, compiler.types.voidType.element) || |
| 1756 identical(element, compiler.dynamicClass)) { | 1750 identical(element, compiler.dynamicClass)) { |
| 1757 type = checkNoTypeArguments(element.computeType(compiler)); | 1751 type = checkNoTypeArguments(element.computeType(compiler)); |
| 1758 } else if (element.isClass()) { | 1752 } else if (element.isClass()) { |
| 1759 ClassElement cls = element; | 1753 ClassElement cls = element; |
| 1760 compiler.resolver._ensureClassWillBeResolved(cls); | 1754 compiler.resolver._ensureClassWillBeResolved(cls); |
| 1761 element.computeType(compiler); | 1755 element.computeType(compiler); |
| 1762 var arguments = new LinkBuilder<DartType>(); | 1756 List<DartType> arguments = <DartType>[]; |
| 1763 bool hasTypeArgumentMismatch = resolveTypeArguments( | 1757 bool hasTypeArgumentMismatch = resolveTypeArguments( |
| 1764 visitor, node, cls.typeVariables, arguments); | 1758 visitor, node, cls.typeVariables, arguments); |
| 1765 if (hasTypeArgumentMismatch) { | 1759 if (hasTypeArgumentMismatch) { |
| 1766 type = new BadInterfaceType(cls.declaration, | 1760 type = new BadInterfaceType(cls.declaration, |
| 1767 new InterfaceType.forUserProvidedBadType(cls.declaration, | 1761 new InterfaceType.forUserProvidedBadType(cls.declaration, |
| 1768 arguments.toLink())); | 1762 arguments)); |
| 1769 } else { | 1763 } else { |
| 1770 if (arguments.isEmpty) { | 1764 if (arguments.isEmpty) { |
| 1771 type = cls.rawType; | 1765 type = cls.rawType; |
| 1772 } else { | 1766 } else { |
| 1773 type = new InterfaceType(cls.declaration, arguments.toLink()); | 1767 type = new InterfaceType(cls.declaration, arguments); |
| 1774 addTypeVariableBoundsCheck = true; | 1768 addTypeVariableBoundsCheck = true; |
| 1775 } | 1769 } |
| 1776 } | 1770 } |
| 1777 } else if (element.isTypedef()) { | 1771 } else if (element.isTypedef()) { |
| 1778 TypedefElement typdef = element; | 1772 TypedefElement typdef = element; |
| 1779 // TODO(ahe): Should be [ensureResolved]. | 1773 // TODO(ahe): Should be [ensureResolved]. |
| 1780 compiler.resolveTypedef(typdef); | 1774 compiler.resolveTypedef(typdef); |
| 1781 var arguments = new LinkBuilder<DartType>(); | 1775 List<DartType> arguments = <DartType>[]; |
| 1782 bool hasTypeArgumentMismatch = resolveTypeArguments( | 1776 bool hasTypeArgumentMismatch = resolveTypeArguments( |
| 1783 visitor, node, typdef.typeVariables, arguments); | 1777 visitor, node, typdef.typeVariables, arguments); |
| 1784 if (hasTypeArgumentMismatch) { | 1778 if (hasTypeArgumentMismatch) { |
| 1785 type = new BadTypedefType(typdef, | 1779 type = new BadTypedefType(typdef, |
| 1786 new TypedefType.forUserProvidedBadType(typdef, | 1780 new TypedefType.forUserProvidedBadType(typdef, arguments)); |
| 1787 arguments.toLink())); | |
| 1788 } else { | 1781 } else { |
| 1789 if (arguments.isEmpty) { | 1782 if (arguments.isEmpty) { |
| 1790 type = typdef.rawType; | 1783 type = typdef.rawType; |
| 1791 } else { | 1784 } else { |
| 1792 type = new TypedefType(typdef, arguments.toLink()); | 1785 type = new TypedefType(typdef, arguments); |
| 1793 addTypeVariableBoundsCheck = true; | 1786 addTypeVariableBoundsCheck = true; |
| 1794 } | 1787 } |
| 1795 } | 1788 } |
| 1796 } else if (element.isTypeVariable()) { | 1789 } else if (element.isTypeVariable()) { |
| 1797 Element outer = | 1790 Element outer = |
| 1798 visitor.enclosingElement.getOutermostEnclosingMemberOrTopLevel(); | 1791 visitor.enclosingElement.getOutermostEnclosingMemberOrTopLevel(); |
| 1799 bool isInFactoryConstructor = | 1792 bool isInFactoryConstructor = |
| 1800 outer != null && outer.isFactoryConstructor(); | 1793 outer != null && outer.isFactoryConstructor(); |
| 1801 if (!outer.isClass() && | 1794 if (!outer.isClass() && |
| 1802 !outer.isTypedef() && | 1795 !outer.isTypedef() && |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1848 | 1841 |
| 1849 compiler.types.checkTypeVariableBounds(type, checkTypeVariableBound); | 1842 compiler.types.checkTypeVariableBounds(type, checkTypeVariableBound); |
| 1850 } | 1843 } |
| 1851 | 1844 |
| 1852 /** | 1845 /** |
| 1853 * Resolves the type arguments of [node] and adds these to [arguments]. | 1846 * Resolves the type arguments of [node] and adds these to [arguments]. |
| 1854 * | 1847 * |
| 1855 * Returns [: true :] if the number of type arguments did not match the | 1848 * Returns [: true :] if the number of type arguments did not match the |
| 1856 * number of type variables. | 1849 * number of type variables. |
| 1857 */ | 1850 */ |
| 1858 bool resolveTypeArguments( | 1851 bool resolveTypeArguments(MappingVisitor visitor, |
| 1859 MappingVisitor visitor, | 1852 TypeAnnotation node, |
| 1860 TypeAnnotation node, | 1853 List<DartType> typeVariables, |
| 1861 Link<DartType> typeVariables, | 1854 List<DartType> arguments) { |
| 1862 LinkBuilder<DartType> arguments) { | |
| 1863 if (node.typeArguments == null) { | 1855 if (node.typeArguments == null) { |
| 1864 return false; | 1856 return false; |
| 1865 } | 1857 } |
| 1858 int expectedVariables = |
| 1859 typeVariables != null ? typeVariables.length : arguments.length; |
| 1860 int index = 0; |
| 1866 bool typeArgumentCountMismatch = false; | 1861 bool typeArgumentCountMismatch = false; |
| 1867 for (Link<Node> typeArguments = node.typeArguments.nodes; | 1862 for (Link<Node> typeArguments = node.typeArguments.nodes; |
| 1868 !typeArguments.isEmpty; | 1863 !typeArguments.isEmpty; |
| 1869 typeArguments = typeArguments.tail) { | 1864 typeArguments = typeArguments.tail, index++) { |
| 1870 if (typeVariables != null && typeVariables.isEmpty) { | 1865 if (index > expectedVariables - 1) { |
| 1871 visitor.warning( | 1866 visitor.warning( |
| 1872 typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); | 1867 typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); |
| 1873 typeArgumentCountMismatch = true; | 1868 typeArgumentCountMismatch = true; |
| 1874 } | 1869 } |
| 1875 DartType argType = resolveTypeAnnotation(visitor, typeArguments.head); | 1870 DartType argType = resolveTypeAnnotation(visitor, typeArguments.head); |
| 1876 arguments.addLast(argType); | 1871 arguments.add(argType); |
| 1877 if (typeVariables != null && !typeVariables.isEmpty) { | |
| 1878 typeVariables = typeVariables.tail; | |
| 1879 } | |
| 1880 } | 1872 } |
| 1881 if (typeVariables != null && !typeVariables.isEmpty) { | 1873 if (index < expectedVariables) { |
| 1882 visitor.warning(node.typeArguments, | 1874 visitor.warning(node.typeArguments, |
| 1883 MessageKind.MISSING_TYPE_ARGUMENT); | 1875 MessageKind.MISSING_TYPE_ARGUMENT); |
| 1884 typeArgumentCountMismatch = true; | 1876 typeArgumentCountMismatch = true; |
| 1885 } | 1877 } |
| 1886 return typeArgumentCountMismatch; | 1878 return typeArgumentCountMismatch; |
| 1887 } | 1879 } |
| 1888 } | 1880 } |
| 1889 | 1881 |
| 1890 /** | 1882 /** |
| 1891 * Common supertype for resolver visitors that record resolutions in a | 1883 * Common supertype for resolver visitors that record resolutions in a |
| (...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3190 resolveTypeAnnotation(nodes.head); | 3182 resolveTypeAnnotation(nodes.head); |
| 3191 } | 3183 } |
| 3192 } | 3184 } |
| 3193 } | 3185 } |
| 3194 DartType listType; | 3186 DartType listType; |
| 3195 if (typeArgument != null) { | 3187 if (typeArgument != null) { |
| 3196 if (node.isConst() && typeArgument.containsTypeVariables) { | 3188 if (node.isConst() && typeArgument.containsTypeVariables) { |
| 3197 compiler.reportError(arguments.nodes.head, | 3189 compiler.reportError(arguments.nodes.head, |
| 3198 MessageKind.TYPE_VARIABLE_IN_CONSTANT); | 3190 MessageKind.TYPE_VARIABLE_IN_CONSTANT); |
| 3199 } | 3191 } |
| 3200 listType = new InterfaceType(compiler.listClass, | 3192 listType = new InterfaceType(compiler.listClass, [typeArgument]); |
| 3201 new Link<DartType>.fromList([typeArgument])); | |
| 3202 } else { | 3193 } else { |
| 3203 compiler.listClass.computeType(compiler); | 3194 compiler.listClass.computeType(compiler); |
| 3204 listType = compiler.listClass.rawType; | 3195 listType = compiler.listClass.rawType; |
| 3205 } | 3196 } |
| 3206 mapping.setType(node, listType); | 3197 mapping.setType(node, listType); |
| 3207 world.registerInstantiatedType(listType, mapping); | 3198 world.registerInstantiatedType(listType, mapping); |
| 3208 compiler.backend.registerRequiredType(listType, enclosingElement); | 3199 compiler.backend.registerRequiredType(listType, enclosingElement); |
| 3209 visit(node.elements); | 3200 visit(node.elements); |
| 3210 if (node.isConst()) { | 3201 if (node.isConst()) { |
| 3211 analyzeConstant(node); | 3202 analyzeConstant(node); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3408 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) { | 3399 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) { |
| 3409 warning(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); | 3400 warning(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); |
| 3410 resolveTypeAnnotation(nodes.head); | 3401 resolveTypeAnnotation(nodes.head); |
| 3411 } | 3402 } |
| 3412 } | 3403 } |
| 3413 } | 3404 } |
| 3414 } | 3405 } |
| 3415 DartType mapType; | 3406 DartType mapType; |
| 3416 if (valueTypeArgument != null) { | 3407 if (valueTypeArgument != null) { |
| 3417 mapType = new InterfaceType(compiler.mapClass, | 3408 mapType = new InterfaceType(compiler.mapClass, |
| 3418 new Link<DartType>.fromList([keyTypeArgument, valueTypeArgument])); | 3409 [keyTypeArgument, valueTypeArgument]); |
| 3419 } else { | 3410 } else { |
| 3420 compiler.mapClass.computeType(compiler); | 3411 compiler.mapClass.computeType(compiler); |
| 3421 mapType = compiler.mapClass.rawType; | 3412 mapType = compiler.mapClass.rawType; |
| 3422 } | 3413 } |
| 3423 if (node.isConst() && mapType.containsTypeVariables) { | 3414 if (node.isConst() && mapType.containsTypeVariables) { |
| 3424 compiler.reportError(arguments, | 3415 compiler.reportError(arguments, |
| 3425 MessageKind.TYPE_VARIABLE_IN_CONSTANT); | 3416 MessageKind.TYPE_VARIABLE_IN_CONSTANT); |
| 3426 } | 3417 } |
| 3427 mapping.setType(node, mapType); | 3418 mapping.setType(node, mapType); |
| 3428 world.registerInstantiatedType(mapType, mapping); | 3419 world.registerInstantiatedType(mapType, mapping); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3616 TreeElementMapping mapping) | 3607 TreeElementMapping mapping) |
| 3617 : this.enclosingElement = element, | 3608 : this.enclosingElement = element, |
| 3618 scope = Scope.buildEnclosingScope(element), | 3609 scope = Scope.buildEnclosingScope(element), |
| 3619 super(compiler, mapping); | 3610 super(compiler, mapping); |
| 3620 | 3611 |
| 3621 DartType get objectType => compiler.objectClass.rawType; | 3612 DartType get objectType => compiler.objectClass.rawType; |
| 3622 | 3613 |
| 3623 void resolveTypeVariableBounds(NodeList node) { | 3614 void resolveTypeVariableBounds(NodeList node) { |
| 3624 if (node == null) return; | 3615 if (node == null) return; |
| 3625 | 3616 |
| 3626 var nameSet = new Setlet<String>(); | 3617 Setlet<String> nameSet = new Setlet<String>(); |
| 3627 // Resolve the bounds of type variables. | 3618 // Resolve the bounds of type variables. |
| 3628 Link<DartType> typeLink = element.typeVariables; | 3619 Iterator<DartType> types = element.typeVariables.iterator; |
| 3629 Link<Node> nodeLink = node.nodes; | 3620 Link<Node> nodeLink = node.nodes; |
| 3630 while (!nodeLink.isEmpty) { | 3621 while (!nodeLink.isEmpty) { |
| 3631 TypeVariableType typeVariable = typeLink.head; | 3622 types.moveNext(); |
| 3623 TypeVariableType typeVariable = types.current; |
| 3632 String typeName = typeVariable.name; | 3624 String typeName = typeVariable.name; |
| 3633 TypeVariable typeNode = nodeLink.head; | 3625 TypeVariable typeNode = nodeLink.head; |
| 3634 if (nameSet.contains(typeName)) { | 3626 if (nameSet.contains(typeName)) { |
| 3635 error(typeNode, MessageKind.DUPLICATE_TYPE_VARIABLE_NAME, | 3627 error(typeNode, MessageKind.DUPLICATE_TYPE_VARIABLE_NAME, |
| 3636 {'typeVariableName': typeName}); | 3628 {'typeVariableName': typeName}); |
| 3637 } | 3629 } |
| 3638 nameSet.add(typeName); | 3630 nameSet.add(typeName); |
| 3639 | 3631 |
| 3640 TypeVariableElement variableElement = typeVariable.element; | 3632 TypeVariableElement variableElement = typeVariable.element; |
| 3641 if (typeNode.bound != null) { | 3633 if (typeNode.bound != null) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 3661 } | 3653 } |
| 3662 seenTypeVariables = seenTypeVariables.prepend(element); | 3654 seenTypeVariables = seenTypeVariables.prepend(element); |
| 3663 bound = element.bound; | 3655 bound = element.bound; |
| 3664 } | 3656 } |
| 3665 } | 3657 } |
| 3666 addDeferredAction(element, checkTypeVariableBound); | 3658 addDeferredAction(element, checkTypeVariableBound); |
| 3667 } else { | 3659 } else { |
| 3668 variableElement.bound = objectType; | 3660 variableElement.bound = objectType; |
| 3669 } | 3661 } |
| 3670 nodeLink = nodeLink.tail; | 3662 nodeLink = nodeLink.tail; |
| 3671 typeLink = typeLink.tail; | |
| 3672 } | 3663 } |
| 3673 assert(typeLink.isEmpty); | 3664 assert(!types.moveNext()); |
| 3674 } | 3665 } |
| 3675 } | 3666 } |
| 3676 | 3667 |
| 3677 class TypedefResolverVisitor extends TypeDefinitionVisitor { | 3668 class TypedefResolverVisitor extends TypeDefinitionVisitor { |
| 3678 TypedefElement get element => enclosingElement; | 3669 TypedefElement get element => enclosingElement; |
| 3679 | 3670 |
| 3680 TypedefResolverVisitor(Compiler compiler, | 3671 TypedefResolverVisitor(Compiler compiler, |
| 3681 TypedefElement typedefElement, | 3672 TypedefElement typedefElement, |
| 3682 TreeElementMapping mapping) | 3673 TreeElementMapping mapping) |
| 3683 : super(compiler, typedefElement, mapping); | 3674 : super(compiler, typedefElement, mapping); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3941 DartType applyMixin(DartType supertype, DartType mixinType, Node node) { | 3932 DartType applyMixin(DartType supertype, DartType mixinType, Node node) { |
| 3942 String superName = supertype.name; | 3933 String superName = supertype.name; |
| 3943 String mixinName = mixinType.name; | 3934 String mixinName = mixinType.name; |
| 3944 MixinApplicationElementX mixinApplication = new MixinApplicationElementX( | 3935 MixinApplicationElementX mixinApplication = new MixinApplicationElementX( |
| 3945 "${superName}+${mixinName}", | 3936 "${superName}+${mixinName}", |
| 3946 element.getCompilationUnit(), | 3937 element.getCompilationUnit(), |
| 3947 compiler.getNextFreeClassId(), | 3938 compiler.getNextFreeClassId(), |
| 3948 node, | 3939 node, |
| 3949 new Modifiers.withFlags(new NodeList.empty(), Modifiers.FLAG_ABSTRACT)); | 3940 new Modifiers.withFlags(new NodeList.empty(), Modifiers.FLAG_ABSTRACT)); |
| 3950 // Create synthetic type variables for the mixin application. | 3941 // Create synthetic type variables for the mixin application. |
| 3951 LinkBuilder<DartType> typeVariablesBuilder = new LinkBuilder<DartType>(); | 3942 List<DartType> typeVariables = <DartType>[]; |
| 3952 element.typeVariables.forEach((TypeVariableType type) { | 3943 element.typeVariables.forEach((TypeVariableType type) { |
| 3953 TypeVariableElementX typeVariableElement = new TypeVariableElementX( | 3944 TypeVariableElementX typeVariableElement = new TypeVariableElementX( |
| 3954 type.name, mixinApplication, type.element.parseNode(compiler)); | 3945 type.name, mixinApplication, type.element.parseNode(compiler)); |
| 3955 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement); | 3946 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement); |
| 3956 typeVariablesBuilder.addLast(typeVariable); | 3947 typeVariables.add(typeVariable); |
| 3957 }); | 3948 }); |
| 3958 Link<DartType> typeVariables = typeVariablesBuilder.toLink(); | |
| 3959 // Setup bounds on the synthetic type variables. | 3949 // Setup bounds on the synthetic type variables. |
| 3960 Link<DartType> link = typeVariables; | 3950 List<DartType> link = typeVariables; |
| 3951 int index = 0; |
| 3961 element.typeVariables.forEach((TypeVariableType type) { | 3952 element.typeVariables.forEach((TypeVariableType type) { |
| 3962 TypeVariableType typeVariable = link.head; | 3953 TypeVariableType typeVariable = typeVariables[index++]; |
| 3963 TypeVariableElement typeVariableElement = typeVariable.element; | 3954 TypeVariableElement typeVariableElement = typeVariable.element; |
| 3964 typeVariableElement.type = typeVariable; | 3955 typeVariableElement.type = typeVariable; |
| 3965 typeVariableElement.bound = | 3956 typeVariableElement.bound = |
| 3966 type.element.bound.subst(typeVariables, element.typeVariables); | 3957 type.element.bound.subst(typeVariables, element.typeVariables); |
| 3967 link = link.tail; | |
| 3968 }); | 3958 }); |
| 3969 // Setup this and raw type for the mixin application. | 3959 // Setup this and raw type for the mixin application. |
| 3970 mixinApplication.computeThisAndRawType(compiler, typeVariables); | 3960 mixinApplication.computeThisAndRawType(compiler, typeVariables); |
| 3971 // Substitute in synthetic type variables in super and mixin types. | 3961 // Substitute in synthetic type variables in super and mixin types. |
| 3972 supertype = supertype.subst(typeVariables, element.typeVariables); | 3962 supertype = supertype.subst(typeVariables, element.typeVariables); |
| 3973 mixinType = mixinType.subst(typeVariables, element.typeVariables); | 3963 mixinType = mixinType.subst(typeVariables, element.typeVariables); |
| 3974 | 3964 |
| 3975 doApplyMixinTo(mixinApplication, supertype, mixinType); | 3965 doApplyMixinTo(mixinApplication, supertype, mixinType); |
| 3976 mixinApplication.resolutionState = STATE_DONE; | 3966 mixinApplication.resolutionState = STATE_DONE; |
| 3977 mixinApplication.supertypeLoadState = STATE_DONE; | 3967 mixinApplication.supertypeLoadState = STATE_DONE; |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4523 return finishConstructorReference(visit(expression), | 4513 return finishConstructorReference(visit(expression), |
| 4524 expression, expression); | 4514 expression, expression); |
| 4525 } | 4515 } |
| 4526 } | 4516 } |
| 4527 | 4517 |
| 4528 /// Looks up [name] in [scope] and unwraps the result. | 4518 /// Looks up [name] in [scope] and unwraps the result. |
| 4529 Element lookupInScope(Compiler compiler, Node node, | 4519 Element lookupInScope(Compiler compiler, Node node, |
| 4530 Scope scope, String name) { | 4520 Scope scope, String name) { |
| 4531 return Elements.unwrap(scope.lookup(name), compiler, node); | 4521 return Elements.unwrap(scope.lookup(name), compiler, node); |
| 4532 } | 4522 } |
| OLD | NEW |