| 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 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1697 | 1697 |
| 1698 DartType resolveTypeAnnotation(MappingVisitor visitor, TypeAnnotation node, | 1698 DartType resolveTypeAnnotation(MappingVisitor visitor, TypeAnnotation node, |
| 1699 {bool malformedIsError: false, | 1699 {bool malformedIsError: false, |
| 1700 bool deferredIsMalformed: true}) { | 1700 bool deferredIsMalformed: true}) { |
| 1701 ResolutionRegistry registry = visitor.registry; | 1701 ResolutionRegistry registry = visitor.registry; |
| 1702 | 1702 |
| 1703 Identifier typeName; | 1703 Identifier typeName; |
| 1704 DartType type; | 1704 DartType type; |
| 1705 | 1705 |
| 1706 DartType checkNoTypeArguments(DartType type) { | 1706 DartType checkNoTypeArguments(DartType type) { |
| 1707 LinkBuilder<DartType> arguments = new LinkBuilder<DartType>(); | 1707 List<DartType> arguments = new List<DartType>(); |
| 1708 bool hasTypeArgumentMismatch = resolveTypeArguments( | 1708 bool hasTypeArgumentMismatch = resolveTypeArguments( |
| 1709 visitor, node, const Link<DartType>(), arguments); | 1709 visitor, node, const <DartType>[], arguments); |
| 1710 if (hasTypeArgumentMismatch) { | 1710 if (hasTypeArgumentMismatch) { |
| 1711 return new MalformedType( | 1711 return new MalformedType( |
| 1712 new ErroneousElementX(MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH, | 1712 new ErroneousElementX(MessageKind.TYPE_ARGUMENT_COUNT_MISMATCH, |
| 1713 {'type': node}, typeName.source, visitor.enclosingElement), | 1713 {'type': node}, typeName.source, visitor.enclosingElement), |
| 1714 type, arguments.toLink()); | 1714 type, arguments); |
| 1715 } | 1715 } |
| 1716 return type; | 1716 return type; |
| 1717 } | 1717 } |
| 1718 | 1718 |
| 1719 Identifier prefixName; | 1719 Identifier prefixName; |
| 1720 Send send = node.typeName.asSend(); | 1720 Send send = node.typeName.asSend(); |
| 1721 if (send != null) { | 1721 if (send != null) { |
| 1722 // The type name is of the form [: prefix . identifier :]. | 1722 // The type name is of the form [: prefix . identifier :]. |
| 1723 prefixName = send.receiver.asIdentifier(); | 1723 prefixName = send.receiver.asIdentifier(); |
| 1724 typeName = send.selector.asIdentifier(); | 1724 typeName = send.selector.asIdentifier(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1748 visitor.error(node, messageKind, messageArguments); | 1748 visitor.error(node, messageKind, messageArguments); |
| 1749 } else { | 1749 } else { |
| 1750 registry.registerThrowRuntimeError(); | 1750 registry.registerThrowRuntimeError(); |
| 1751 visitor.warning(node, messageKind, messageArguments); | 1751 visitor.warning(node, messageKind, messageArguments); |
| 1752 } | 1752 } |
| 1753 if (erroneousElement == null) { | 1753 if (erroneousElement == null) { |
| 1754 erroneousElement = new ErroneousElementX( | 1754 erroneousElement = new ErroneousElementX( |
| 1755 messageKind, messageArguments, typeName.source, | 1755 messageKind, messageArguments, typeName.source, |
| 1756 visitor.enclosingElement); | 1756 visitor.enclosingElement); |
| 1757 } | 1757 } |
| 1758 LinkBuilder<DartType> arguments = new LinkBuilder<DartType>(); | 1758 List<DartType> arguments = <DartType>[]; |
| 1759 resolveTypeArguments(visitor, node, null, arguments); | 1759 resolveTypeArguments(visitor, node, const <DartType>[], arguments); |
| 1760 return new MalformedType(erroneousElement, | 1760 return new MalformedType(erroneousElement, |
| 1761 userProvidedBadType, arguments.toLink()); | 1761 userProvidedBadType, arguments); |
| 1762 } | 1762 } |
| 1763 | 1763 |
| 1764 // Try to construct the type from the element. | 1764 // Try to construct the type from the element. |
| 1765 if (element == null) { | 1765 if (element == null) { |
| 1766 type = reportFailureAndCreateType( | 1766 type = reportFailureAndCreateType( |
| 1767 MessageKind.CANNOT_RESOLVE_TYPE, {'typeName': node.typeName}); | 1767 MessageKind.CANNOT_RESOLVE_TYPE, {'typeName': node.typeName}); |
| 1768 } else if (element.isAmbiguous) { | 1768 } else if (element.isAmbiguous) { |
| 1769 AmbiguousElement ambiguous = element; | 1769 AmbiguousElement ambiguous = element; |
| 1770 type = reportFailureAndCreateType( | 1770 type = reportFailureAndCreateType( |
| 1771 ambiguous.messageKind, ambiguous.messageArguments); | 1771 ambiguous.messageKind, ambiguous.messageArguments); |
| 1772 ambiguous.diagnose(registry.currentElement, compiler); | 1772 ambiguous.diagnose(registry.currentElement, compiler); |
| 1773 } else if (element.isErroneous) { | 1773 } else if (element.isErroneous) { |
| 1774 ErroneousElement erroneousElement = element; | 1774 ErroneousElement erroneousElement = element; |
| 1775 type = reportFailureAndCreateType( | 1775 type = reportFailureAndCreateType( |
| 1776 erroneousElement.messageKind, erroneousElement.messageArguments, | 1776 erroneousElement.messageKind, erroneousElement.messageArguments, |
| 1777 erroneousElement: erroneousElement); | 1777 erroneousElement: erroneousElement); |
| 1778 } else if (!element.impliesType) { | 1778 } else if (!element.impliesType) { |
| 1779 type = reportFailureAndCreateType( | 1779 type = reportFailureAndCreateType( |
| 1780 MessageKind.NOT_A_TYPE, {'node': node.typeName}); | 1780 MessageKind.NOT_A_TYPE, {'node': node.typeName}); |
| 1781 } else { | 1781 } else { |
| 1782 bool addTypeVariableBoundsCheck = false; | 1782 bool addTypeVariableBoundsCheck = false; |
| 1783 if (element.isClass) { | 1783 if (element.isClass) { |
| 1784 ClassElement cls = element; | 1784 ClassElement cls = element; |
| 1785 // TODO(johnniwinther): [_ensureClassWillBeResolved] should imply | 1785 // TODO(johnniwinther): [_ensureClassWillBeResolved] should imply |
| 1786 // [computeType]. | 1786 // [computeType]. |
| 1787 compiler.resolver._ensureClassWillBeResolved(cls); | 1787 compiler.resolver._ensureClassWillBeResolved(cls); |
| 1788 element.computeType(compiler); | 1788 element.computeType(compiler); |
| 1789 var arguments = new LinkBuilder<DartType>(); | 1789 List<DartType> arguments = <DartType>[]; |
| 1790 bool hasTypeArgumentMismatch = resolveTypeArguments( | 1790 bool hasTypeArgumentMismatch = resolveTypeArguments( |
| 1791 visitor, node, cls.typeVariables, arguments); | 1791 visitor, node, cls.typeVariables, arguments); |
| 1792 if (hasTypeArgumentMismatch) { | 1792 if (hasTypeArgumentMismatch) { |
| 1793 type = new BadInterfaceType(cls.declaration, | 1793 type = new BadInterfaceType(cls.declaration, |
| 1794 new InterfaceType.forUserProvidedBadType(cls.declaration, | 1794 new InterfaceType.forUserProvidedBadType(cls.declaration, |
| 1795 arguments.toLink())); | 1795 arguments)); |
| 1796 } else { | 1796 } else { |
| 1797 if (arguments.isEmpty) { | 1797 if (arguments.isEmpty) { |
| 1798 type = cls.rawType; | 1798 type = cls.rawType; |
| 1799 } else { | 1799 } else { |
| 1800 type = new InterfaceType(cls.declaration, arguments.toLink()); | 1800 type = new InterfaceType(cls.declaration, arguments.toList(growable:
false)); |
| 1801 addTypeVariableBoundsCheck = true; | 1801 addTypeVariableBoundsCheck = true; |
| 1802 } | 1802 } |
| 1803 } | 1803 } |
| 1804 } else if (element.isTypedef) { | 1804 } else if (element.isTypedef) { |
| 1805 TypedefElement typdef = element; | 1805 TypedefElement typdef = element; |
| 1806 // TODO(johnniwinther): [ensureResolved] should imply [computeType]. | 1806 // TODO(johnniwinther): [ensureResolved] should imply [computeType]. |
| 1807 typdef.ensureResolved(compiler); | 1807 typdef.ensureResolved(compiler); |
| 1808 element.computeType(compiler); | 1808 element.computeType(compiler); |
| 1809 var arguments = new LinkBuilder<DartType>(); | 1809 List<DartType> arguments = <DartType>[]; |
| 1810 bool hasTypeArgumentMismatch = resolveTypeArguments( | 1810 bool hasTypeArgumentMismatch = resolveTypeArguments( |
| 1811 visitor, node, typdef.typeVariables, arguments); | 1811 visitor, node, typdef.typeVariables, arguments); |
| 1812 if (hasTypeArgumentMismatch) { | 1812 if (hasTypeArgumentMismatch) { |
| 1813 type = new BadTypedefType(typdef, | 1813 type = new BadTypedefType(typdef, |
| 1814 new TypedefType.forUserProvidedBadType(typdef, | 1814 new TypedefType.forUserProvidedBadType(typdef, arguments)); |
| 1815 arguments.toLink())); | |
| 1816 } else { | 1815 } else { |
| 1817 if (arguments.isEmpty) { | 1816 if (arguments.isEmpty) { |
| 1818 type = typdef.rawType; | 1817 type = typdef.rawType; |
| 1819 } else { | 1818 } else { |
| 1820 type = new TypedefType(typdef, arguments.toLink()); | 1819 type = new TypedefType(typdef, arguments.toList(growable: false)); |
| 1821 addTypeVariableBoundsCheck = true; | 1820 addTypeVariableBoundsCheck = true; |
| 1822 } | 1821 } |
| 1823 } | 1822 } |
| 1824 } else if (element.isTypeVariable) { | 1823 } else if (element.isTypeVariable) { |
| 1825 Element outer = | 1824 Element outer = |
| 1826 visitor.enclosingElement.outermostEnclosingMemberOrTopLevel; | 1825 visitor.enclosingElement.outermostEnclosingMemberOrTopLevel; |
| 1827 bool isInFactoryConstructor = | 1826 bool isInFactoryConstructor = |
| 1828 outer != null && outer.isFactoryConstructor; | 1827 outer != null && outer.isFactoryConstructor; |
| 1829 if (!outer.isClass && | 1828 if (!outer.isClass && |
| 1830 !outer.isTypedef && | 1829 !outer.isTypedef && |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1871 | 1870 |
| 1872 compiler.types.checkTypeVariableBounds(type, checkTypeVariableBound); | 1871 compiler.types.checkTypeVariableBounds(type, checkTypeVariableBound); |
| 1873 } | 1872 } |
| 1874 | 1873 |
| 1875 /** | 1874 /** |
| 1876 * Resolves the type arguments of [node] and adds these to [arguments]. | 1875 * Resolves the type arguments of [node] and adds these to [arguments]. |
| 1877 * | 1876 * |
| 1878 * Returns [: true :] if the number of type arguments did not match the | 1877 * Returns [: true :] if the number of type arguments did not match the |
| 1879 * number of type variables. | 1878 * number of type variables. |
| 1880 */ | 1879 */ |
| 1881 bool resolveTypeArguments( | 1880 bool resolveTypeArguments(MappingVisitor visitor, |
| 1882 MappingVisitor visitor, | 1881 TypeAnnotation node, |
| 1883 TypeAnnotation node, | 1882 List<DartType> typeVariables, |
| 1884 Link<DartType> typeVariables, | 1883 List<DartType> arguments) { |
| 1885 LinkBuilder<DartType> arguments) { | |
| 1886 if (node.typeArguments == null) { | 1884 if (node.typeArguments == null) { |
| 1887 return false; | 1885 return false; |
| 1888 } | 1886 } |
| 1887 int expectedVariables = typeVariables.length; |
| 1888 assert(arguments.length == expectedVariables); |
| 1889 int index = 0; |
| 1889 bool typeArgumentCountMismatch = false; | 1890 bool typeArgumentCountMismatch = false; |
| 1890 for (Link<Node> typeArguments = node.typeArguments.nodes; | 1891 for (Link<Node> typeArguments = node.typeArguments.nodes; |
| 1891 !typeArguments.isEmpty; | 1892 !typeArguments.isEmpty; |
| 1892 typeArguments = typeArguments.tail) { | 1893 typeArguments = typeArguments.tail, index++) { |
| 1893 if (typeVariables != null && typeVariables.isEmpty) { | 1894 if (index > expectedVariables - 1) { |
| 1894 visitor.warning( | 1895 visitor.warning( |
| 1895 typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); | 1896 typeArguments.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); |
| 1896 typeArgumentCountMismatch = true; | 1897 typeArgumentCountMismatch = true; |
| 1897 } | 1898 } |
| 1898 DartType argType = resolveTypeAnnotation(visitor, typeArguments.head); | 1899 DartType argType = resolveTypeAnnotation(visitor, typeArguments.head); |
| 1899 arguments.addLast(argType); | 1900 // TODO(karlklose): rewrite to not modify [arguments]. |
| 1900 if (typeVariables != null && !typeVariables.isEmpty) { | 1901 arguments.add(argType); |
| 1901 typeVariables = typeVariables.tail; | |
| 1902 } | |
| 1903 } | 1902 } |
| 1904 if (typeVariables != null && !typeVariables.isEmpty) { | 1903 if (index < expectedVariables) { |
| 1905 visitor.warning(node.typeArguments, | 1904 visitor.warning(node.typeArguments, |
| 1906 MessageKind.MISSING_TYPE_ARGUMENT); | 1905 MessageKind.MISSING_TYPE_ARGUMENT); |
| 1907 typeArgumentCountMismatch = true; | 1906 typeArgumentCountMismatch = true; |
| 1908 } | 1907 } |
| 1909 return typeArgumentCountMismatch; | 1908 return typeArgumentCountMismatch; |
| 1910 } | 1909 } |
| 1911 } | 1910 } |
| 1912 | 1911 |
| 1913 /** | 1912 /** |
| 1914 * Common supertype for resolver visitors that record resolutions in a | 1913 * Common supertype for resolver visitors that record resolutions in a |
| (...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3245 resolveTypeAnnotation(nodes.head); | 3244 resolveTypeAnnotation(nodes.head); |
| 3246 } | 3245 } |
| 3247 } | 3246 } |
| 3248 } | 3247 } |
| 3249 DartType listType; | 3248 DartType listType; |
| 3250 if (typeArgument != null) { | 3249 if (typeArgument != null) { |
| 3251 if (node.isConst && typeArgument.containsTypeVariables) { | 3250 if (node.isConst && typeArgument.containsTypeVariables) { |
| 3252 compiler.reportError(arguments.nodes.head, | 3251 compiler.reportError(arguments.nodes.head, |
| 3253 MessageKind.TYPE_VARIABLE_IN_CONSTANT); | 3252 MessageKind.TYPE_VARIABLE_IN_CONSTANT); |
| 3254 } | 3253 } |
| 3255 listType = new InterfaceType(compiler.listClass, | 3254 listType = new InterfaceType(compiler.listClass, [typeArgument]); |
| 3256 new Link<DartType>.fromList([typeArgument])); | |
| 3257 } else { | 3255 } else { |
| 3258 compiler.listClass.computeType(compiler); | 3256 compiler.listClass.computeType(compiler); |
| 3259 listType = compiler.listClass.rawType; | 3257 listType = compiler.listClass.rawType; |
| 3260 } | 3258 } |
| 3261 registry.setType(node, listType); | 3259 registry.setType(node, listType); |
| 3262 registry.registerInstantiatedType(listType); | 3260 registry.registerInstantiatedType(listType); |
| 3263 registry.registerRequiredType(listType, enclosingElement); | 3261 registry.registerRequiredType(listType, enclosingElement); |
| 3264 visit(node.elements); | 3262 visit(node.elements); |
| 3265 if (node.isConst) { | 3263 if (node.isConst) { |
| 3266 analyzeConstant(node); | 3264 analyzeConstant(node); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3468 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) { | 3466 for (nodes = nodes.tail; !nodes.isEmpty; nodes = nodes.tail) { |
| 3469 warning(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); | 3467 warning(nodes.head, MessageKind.ADDITIONAL_TYPE_ARGUMENT); |
| 3470 resolveTypeAnnotation(nodes.head); | 3468 resolveTypeAnnotation(nodes.head); |
| 3471 } | 3469 } |
| 3472 } | 3470 } |
| 3473 } | 3471 } |
| 3474 } | 3472 } |
| 3475 DartType mapType; | 3473 DartType mapType; |
| 3476 if (valueTypeArgument != null) { | 3474 if (valueTypeArgument != null) { |
| 3477 mapType = new InterfaceType(compiler.mapClass, | 3475 mapType = new InterfaceType(compiler.mapClass, |
| 3478 new Link<DartType>.fromList([keyTypeArgument, valueTypeArgument])); | 3476 [keyTypeArgument, valueTypeArgument]); |
| 3479 } else { | 3477 } else { |
| 3480 compiler.mapClass.computeType(compiler); | 3478 compiler.mapClass.computeType(compiler); |
| 3481 mapType = compiler.mapClass.rawType; | 3479 mapType = compiler.mapClass.rawType; |
| 3482 } | 3480 } |
| 3483 if (node.isConst && mapType.containsTypeVariables) { | 3481 if (node.isConst && mapType.containsTypeVariables) { |
| 3484 compiler.reportError(arguments, | 3482 compiler.reportError(arguments, |
| 3485 MessageKind.TYPE_VARIABLE_IN_CONSTANT); | 3483 MessageKind.TYPE_VARIABLE_IN_CONSTANT); |
| 3486 } | 3484 } |
| 3487 registry.setType(node, mapType); | 3485 registry.setType(node, mapType); |
| 3488 registry.registerInstantiatedType(mapType); | 3486 registry.registerInstantiatedType(mapType); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3769 ResolutionRegistry registry) | 3767 ResolutionRegistry registry) |
| 3770 : this.enclosingElement = element, | 3768 : this.enclosingElement = element, |
| 3771 scope = Scope.buildEnclosingScope(element), | 3769 scope = Scope.buildEnclosingScope(element), |
| 3772 super(compiler, registry); | 3770 super(compiler, registry); |
| 3773 | 3771 |
| 3774 DartType get objectType => compiler.objectClass.rawType; | 3772 DartType get objectType => compiler.objectClass.rawType; |
| 3775 | 3773 |
| 3776 void resolveTypeVariableBounds(NodeList node) { | 3774 void resolveTypeVariableBounds(NodeList node) { |
| 3777 if (node == null) return; | 3775 if (node == null) return; |
| 3778 | 3776 |
| 3779 var nameSet = new Setlet<String>(); | 3777 Setlet<String> nameSet = new Setlet<String>(); |
| 3780 // Resolve the bounds of type variables. | 3778 // Resolve the bounds of type variables. |
| 3781 Link<DartType> typeLink = element.typeVariables; | 3779 Iterator<DartType> types = element.typeVariables.iterator; |
| 3782 Link<Node> nodeLink = node.nodes; | 3780 Link<Node> nodeLink = node.nodes; |
| 3783 while (!nodeLink.isEmpty) { | 3781 while (!nodeLink.isEmpty) { |
| 3784 TypeVariableType typeVariable = typeLink.head; | 3782 types.moveNext(); |
| 3783 TypeVariableType typeVariable = types.current; |
| 3785 String typeName = typeVariable.name; | 3784 String typeName = typeVariable.name; |
| 3786 TypeVariable typeNode = nodeLink.head; | 3785 TypeVariable typeNode = nodeLink.head; |
| 3787 registry.useType(typeNode, typeVariable); | 3786 registry.useType(typeNode, typeVariable); |
| 3788 if (nameSet.contains(typeName)) { | 3787 if (nameSet.contains(typeName)) { |
| 3789 error(typeNode, MessageKind.DUPLICATE_TYPE_VARIABLE_NAME, | 3788 error(typeNode, MessageKind.DUPLICATE_TYPE_VARIABLE_NAME, |
| 3790 {'typeVariableName': typeName}); | 3789 {'typeVariableName': typeName}); |
| 3791 } | 3790 } |
| 3792 nameSet.add(typeName); | 3791 nameSet.add(typeName); |
| 3793 | 3792 |
| 3794 TypeVariableElementX variableElement = typeVariable.element; | 3793 TypeVariableElementX variableElement = typeVariable.element; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 3815 } | 3814 } |
| 3816 seenTypeVariables = seenTypeVariables.prepend(element); | 3815 seenTypeVariables = seenTypeVariables.prepend(element); |
| 3817 bound = element.bound; | 3816 bound = element.bound; |
| 3818 } | 3817 } |
| 3819 } | 3818 } |
| 3820 addDeferredAction(element, checkTypeVariableBound); | 3819 addDeferredAction(element, checkTypeVariableBound); |
| 3821 } else { | 3820 } else { |
| 3822 variableElement.boundCache = objectType; | 3821 variableElement.boundCache = objectType; |
| 3823 } | 3822 } |
| 3824 nodeLink = nodeLink.tail; | 3823 nodeLink = nodeLink.tail; |
| 3825 typeLink = typeLink.tail; | |
| 3826 } | 3824 } |
| 3827 assert(typeLink.isEmpty); | 3825 assert(!types.moveNext()); |
| 3828 } | 3826 } |
| 3829 } | 3827 } |
| 3830 | 3828 |
| 3831 class TypedefResolverVisitor extends TypeDefinitionVisitor { | 3829 class TypedefResolverVisitor extends TypeDefinitionVisitor { |
| 3832 TypedefElementX get element => enclosingElement; | 3830 TypedefElementX get element => enclosingElement; |
| 3833 | 3831 |
| 3834 TypedefResolverVisitor(Compiler compiler, | 3832 TypedefResolverVisitor(Compiler compiler, |
| 3835 TypedefElement typedefElement, | 3833 TypedefElement typedefElement, |
| 3836 ResolutionRegistry registry) | 3834 ResolutionRegistry registry) |
| 3837 : super(compiler, typedefElement, registry); | 3835 : super(compiler, typedefElement, registry); |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4095 DartType applyMixin(DartType supertype, DartType mixinType, Node node) { | 4093 DartType applyMixin(DartType supertype, DartType mixinType, Node node) { |
| 4096 String superName = supertype.name; | 4094 String superName = supertype.name; |
| 4097 String mixinName = mixinType.name; | 4095 String mixinName = mixinType.name; |
| 4098 MixinApplicationElementX mixinApplication = new MixinApplicationElementX( | 4096 MixinApplicationElementX mixinApplication = new MixinApplicationElementX( |
| 4099 "${superName}+${mixinName}", | 4097 "${superName}+${mixinName}", |
| 4100 element.compilationUnit, | 4098 element.compilationUnit, |
| 4101 compiler.getNextFreeClassId(), | 4099 compiler.getNextFreeClassId(), |
| 4102 node, | 4100 node, |
| 4103 new Modifiers.withFlags(new NodeList.empty(), Modifiers.FLAG_ABSTRACT)); | 4101 new Modifiers.withFlags(new NodeList.empty(), Modifiers.FLAG_ABSTRACT)); |
| 4104 // Create synthetic type variables for the mixin application. | 4102 // Create synthetic type variables for the mixin application. |
| 4105 LinkBuilder<DartType> typeVariablesBuilder = new LinkBuilder<DartType>(); | 4103 List<DartType> typeVariables = <DartType>[]; |
| 4106 element.typeVariables.forEach((TypeVariableType type) { | 4104 element.typeVariables.forEach((TypeVariableType type) { |
| 4107 TypeVariableElementX typeVariableElement = new TypeVariableElementX( | 4105 TypeVariableElementX typeVariableElement = new TypeVariableElementX( |
| 4108 type.name, mixinApplication, type.element.node); | 4106 type.name, mixinApplication, type.element.node); |
| 4109 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement); | 4107 TypeVariableType typeVariable = new TypeVariableType(typeVariableElement); |
| 4110 typeVariablesBuilder.addLast(typeVariable); | 4108 typeVariables.add(typeVariable); |
| 4111 }); | 4109 }); |
| 4112 Link<DartType> typeVariables = typeVariablesBuilder.toLink(); | |
| 4113 // Setup bounds on the synthetic type variables. | 4110 // Setup bounds on the synthetic type variables. |
| 4114 Link<DartType> link = typeVariables; | 4111 List<DartType> link = typeVariables; |
| 4112 int index = 0; |
| 4115 element.typeVariables.forEach((TypeVariableType type) { | 4113 element.typeVariables.forEach((TypeVariableType type) { |
| 4116 TypeVariableType typeVariable = link.head; | 4114 TypeVariableType typeVariable = typeVariables[index++]; |
| 4117 TypeVariableElementX typeVariableElement = typeVariable.element; | 4115 TypeVariableElementX typeVariableElement = typeVariable.element; |
| 4118 typeVariableElement.typeCache = typeVariable; | 4116 typeVariableElement.typeCache = typeVariable; |
| 4119 typeVariableElement.boundCache = | 4117 typeVariableElement.boundCache = |
| 4120 type.element.bound.subst(typeVariables, element.typeVariables); | 4118 type.element.bound.subst(typeVariables, element.typeVariables); |
| 4121 link = link.tail; | |
| 4122 }); | 4119 }); |
| 4123 // Setup this and raw type for the mixin application. | 4120 // Setup this and raw type for the mixin application. |
| 4124 mixinApplication.computeThisAndRawType(compiler, typeVariables); | 4121 mixinApplication.computeThisAndRawType(compiler, typeVariables); |
| 4125 // Substitute in synthetic type variables in super and mixin types. | 4122 // Substitute in synthetic type variables in super and mixin types. |
| 4126 supertype = supertype.subst(typeVariables, element.typeVariables); | 4123 supertype = supertype.subst(typeVariables, element.typeVariables); |
| 4127 mixinType = mixinType.subst(typeVariables, element.typeVariables); | 4124 mixinType = mixinType.subst(typeVariables, element.typeVariables); |
| 4128 | 4125 |
| 4129 doApplyMixinTo(mixinApplication, supertype, mixinType); | 4126 doApplyMixinTo(mixinApplication, supertype, mixinType); |
| 4130 mixinApplication.resolutionState = STATE_DONE; | 4127 mixinApplication.resolutionState = STATE_DONE; |
| 4131 mixinApplication.supertypeLoadState = STATE_DONE; | 4128 mixinApplication.supertypeLoadState = STATE_DONE; |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4704 TreeElements _treeElements; | 4701 TreeElements _treeElements; |
| 4705 | 4702 |
| 4706 bool get hasTreeElements => _treeElements != null; | 4703 bool get hasTreeElements => _treeElements != null; |
| 4707 | 4704 |
| 4708 TreeElements get treeElements { | 4705 TreeElements get treeElements { |
| 4709 assert(invariant(this, _treeElements !=null, | 4706 assert(invariant(this, _treeElements !=null, |
| 4710 message: "TreeElements have not been computed for $this.")); | 4707 message: "TreeElements have not been computed for $this.")); |
| 4711 return _treeElements; | 4708 return _treeElements; |
| 4712 } | 4709 } |
| 4713 } | 4710 } |
| OLD | NEW |