| 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 Set<Node> get superUses; | 9 Set<Node> get superUses; |
| 10 | 10 |
| (...skipping 2711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2722 compiler.reportHint( | 2722 compiler.reportHint( |
| 2723 enclosingElement, MessageKind.MISSING_FACTORY_KEYWORD); | 2723 enclosingElement, MessageKind.MISSING_FACTORY_KEYWORD); |
| 2724 } | 2724 } |
| 2725 FunctionElement redirectionTarget = resolveRedirectingFactory(node); | 2725 FunctionElement redirectionTarget = resolveRedirectingFactory(node); |
| 2726 useElement(node.expression, redirectionTarget); | 2726 useElement(node.expression, redirectionTarget); |
| 2727 FunctionElement constructor = enclosingElement; | 2727 FunctionElement constructor = enclosingElement; |
| 2728 if (constructor.modifiers.isConst() && | 2728 if (constructor.modifiers.isConst() && |
| 2729 !redirectionTarget.modifiers.isConst()) { | 2729 !redirectionTarget.modifiers.isConst()) { |
| 2730 error(node, MessageKind.CONSTRUCTOR_IS_NOT_CONST); | 2730 error(node, MessageKind.CONSTRUCTOR_IS_NOT_CONST); |
| 2731 } | 2731 } |
| 2732 if (redirectionTarget == constructor) { |
| 2733 compiler.reportError(node, MessageKind.CYCLIC_REDIRECTING_FACTORY); |
| 2734 return; |
| 2735 } |
| 2732 constructor.defaultImplementation = redirectionTarget; | 2736 constructor.defaultImplementation = redirectionTarget; |
| 2733 if (Elements.isUnresolved(redirectionTarget)) { | 2737 if (Elements.isUnresolved(redirectionTarget)) { |
| 2734 compiler.backend.registerThrowNoSuchMethod(mapping); | 2738 compiler.backend.registerThrowNoSuchMethod(mapping); |
| 2735 return; | 2739 return; |
| 2736 } | 2740 } |
| 2737 | 2741 |
| 2738 // Check that the target constructor is type compatible with the | 2742 // Check that the target constructor is type compatible with the |
| 2739 // redirecting constructor. | 2743 // redirecting constructor. |
| 2740 ClassElement targetClass = redirectionTarget.getEnclosingClass(); | 2744 ClassElement targetClass = redirectionTarget.getEnclosingClass(); |
| 2741 InterfaceType type = mapping.getType(node.expression); | 2745 InterfaceType type = mapping.getType(node.expression); |
| (...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4527 return finishConstructorReference(visit(expression), | 4531 return finishConstructorReference(visit(expression), |
| 4528 expression, expression); | 4532 expression, expression); |
| 4529 } | 4533 } |
| 4530 } | 4534 } |
| 4531 | 4535 |
| 4532 /// Looks up [name] in [scope] and unwraps the result. | 4536 /// Looks up [name] in [scope] and unwraps the result. |
| 4533 Element lookupInScope(Compiler compiler, Node node, | 4537 Element lookupInScope(Compiler compiler, Node node, |
| 4534 Scope scope, SourceString name) { | 4538 Scope scope, SourceString name) { |
| 4535 return Elements.unwrap(scope.lookup(name), compiler, node); | 4539 return Elements.unwrap(scope.lookup(name), compiler, node); |
| 4536 } | 4540 } |
| OLD | NEW |