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 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 while (!seen.isEmpty) { | 638 while (!seen.isEmpty) { |
639 FunctionElementX factory = seen.removeLast(); | 639 FunctionElementX factory = seen.removeLast(); |
640 | 640 |
641 TreeElements treeElements = | 641 TreeElements treeElements = |
642 compiler.enqueuer.resolution.getCachedElements(factory); | 642 compiler.enqueuer.resolution.getCachedElements(factory); |
643 FunctionExpression functionNode = factory.parseNode(compiler); | 643 FunctionExpression functionNode = factory.parseNode(compiler); |
644 Return redirectionNode = functionNode.body; | 644 Return redirectionNode = functionNode.body; |
645 InterfaceType factoryType = | 645 InterfaceType factoryType = |
646 treeElements.getType(redirectionNode.expression); | 646 treeElements.getType(redirectionNode.expression); |
647 | 647 |
648 targetType = targetType.subst(factoryType.typeArguments, | 648 targetType = targetType.substByContext(factoryType); |
649 factoryType.element.typeVariables); | |
650 factory.redirectionTarget = target; | 649 factory.redirectionTarget = target; |
651 factory.redirectionTargetType = targetType; | 650 factory.redirectionTargetType = targetType; |
652 } | 651 } |
653 } | 652 } |
654 | 653 |
655 /** | 654 /** |
656 * Load and resolve the supertypes of [cls]. | 655 * Load and resolve the supertypes of [cls]. |
657 * | 656 * |
658 * Warning: do not call this method directly. It should only be | 657 * Warning: do not call this method directly. It should only be |
659 * called by [resolveClass] and [ClassSupertypeResolver]. | 658 * called by [resolveClass] and [ClassSupertypeResolver]. |
(...skipping 2071 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2731 node.selector, field.name, MessageKind.CANNOT_RESOLVE_GETTER); | 2730 node.selector, field.name, MessageKind.CANNOT_RESOLVE_GETTER); |
2732 compiler.backend.registerThrowNoSuchMethod(mapping); | 2731 compiler.backend.registerThrowNoSuchMethod(mapping); |
2733 } | 2732 } |
2734 } else if (target.impliesType()) { | 2733 } else if (target.impliesType()) { |
2735 setter = warnAndCreateErroneousElement( | 2734 setter = warnAndCreateErroneousElement( |
2736 node.selector, target.name, MessageKind.ASSIGNING_TYPE); | 2735 node.selector, target.name, MessageKind.ASSIGNING_TYPE); |
2737 compiler.backend.registerThrowNoSuchMethod(mapping); | 2736 compiler.backend.registerThrowNoSuchMethod(mapping); |
2738 } else if (target.modifiers.isFinal() || | 2737 } else if (target.modifiers.isFinal() || |
2739 target.modifiers.isConst() || | 2738 target.modifiers.isConst() || |
2740 (target.isFunction() && | 2739 (target.isFunction() && |
2741 Elements.isStaticOrTopLevelFunction(target) && | 2740 Elements.isStaticOrTopLevelFunction(target) && |
2742 !target.isSetter())) { | 2741 !target.isSetter())) { |
2743 if (target.isFunction()) { | 2742 if (target.isFunction()) { |
2744 setter = warnAndCreateErroneousElement( | 2743 setter = warnAndCreateErroneousElement( |
2745 node.selector, target.name, MessageKind.ASSIGNING_METHOD); | 2744 node.selector, target.name, MessageKind.ASSIGNING_METHOD); |
2746 } else { | 2745 } else { |
2747 setter = warnAndCreateErroneousElement( | 2746 setter = warnAndCreateErroneousElement( |
2748 node.selector, target.name, MessageKind.CANNOT_RESOLVE_SETTER); | 2747 node.selector, target.name, MessageKind.CANNOT_RESOLVE_SETTER); |
2749 } | 2748 } |
2750 compiler.backend.registerThrowNoSuchMethod(mapping); | 2749 compiler.backend.registerThrowNoSuchMethod(mapping); |
2751 } | 2750 } |
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4159 new OrderedTypeSet.singleton(cls.computeType(compiler)); | 4158 new OrderedTypeSet.singleton(cls.computeType(compiler)); |
4160 } | 4159 } |
4161 } | 4160 } |
4162 | 4161 |
4163 /** | 4162 /** |
4164 * Adds [type] and all supertypes of [type] to [allSupertypes] while | 4163 * Adds [type] and all supertypes of [type] to [allSupertypes] while |
4165 * substituting type variables. | 4164 * substituting type variables. |
4166 */ | 4165 */ |
4167 void addAllSupertypes(OrderedTypeSetBuilder allSupertypes, | 4166 void addAllSupertypes(OrderedTypeSetBuilder allSupertypes, |
4168 InterfaceType type) { | 4167 InterfaceType type) { |
4169 Link<DartType> typeArguments = type.typeArguments; | |
4170 ClassElement classElement = type.element; | 4168 ClassElement classElement = type.element; |
4171 Link<DartType> typeVariables = classElement.typeVariables; | |
4172 Link<DartType> supertypes = classElement.allSupertypes; | 4169 Link<DartType> supertypes = classElement.allSupertypes; |
4173 assert(invariant(element, supertypes != null, | 4170 assert(invariant(element, supertypes != null, |
4174 message: "Supertypes not computed on $classElement " | 4171 message: "Supertypes not computed on $classElement " |
4175 "during resolution of $element")); | 4172 "during resolution of $element")); |
4176 while (!supertypes.isEmpty) { | 4173 while (!supertypes.isEmpty) { |
4177 DartType supertype = supertypes.head; | 4174 DartType supertype = supertypes.head; |
4178 allSupertypes.add(compiler, | 4175 allSupertypes.add(compiler, supertype.substByContext(type)); |
4179 supertype.subst(typeArguments, typeVariables)); | |
4180 supertypes = supertypes.tail; | 4176 supertypes = supertypes.tail; |
4181 } | 4177 } |
4182 } | 4178 } |
4183 | 4179 |
4184 isBlackListed(DartType type) { | 4180 isBlackListed(DartType type) { |
4185 LibraryElement lib = element.getLibrary(); | 4181 LibraryElement lib = element.getLibrary(); |
4186 return | 4182 return |
4187 !identical(lib, compiler.coreLibrary) && | 4183 !identical(lib, compiler.coreLibrary) && |
4188 !identical(lib, compiler.jsHelperLibrary) && | 4184 !identical(lib, compiler.jsHelperLibrary) && |
4189 !identical(lib, compiler.interceptorsLibrary) && | 4185 !identical(lib, compiler.interceptorsLibrary) && |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4770 return finishConstructorReference(visit(expression), | 4766 return finishConstructorReference(visit(expression), |
4771 expression, expression); | 4767 expression, expression); |
4772 } | 4768 } |
4773 } | 4769 } |
4774 | 4770 |
4775 /// Looks up [name] in [scope] and unwraps the result. | 4771 /// Looks up [name] in [scope] and unwraps the result. |
4776 Element lookupInScope(Compiler compiler, Node node, | 4772 Element lookupInScope(Compiler compiler, Node node, |
4777 Scope scope, String name) { | 4773 Scope scope, String name) { |
4778 return Elements.unwrap(scope.lookup(name), compiler, node); | 4774 return Elements.unwrap(scope.lookup(name), compiler, node); |
4779 } | 4775 } |
OLD | NEW |