Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(49)

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 27190002: Emit compile-time error if a redirecting factory points to itself. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | tests/co19/co19-dart2js.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698