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

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

Issue 25255002: Emit compile-time errors on illegal variable declarations. (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 | sdk/lib/_internal/compiler/implementation/scanner/listener.dart » ('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 2725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2736 // [VariableListElement.computeType] method. 2736 // [VariableListElement.computeType] method.
2737 if (node.type != null) { 2737 if (node.type != null) {
2738 visitor.variables.type = resolveTypeAnnotation(node.type); 2738 visitor.variables.type = resolveTypeAnnotation(node.type);
2739 } else { 2739 } else {
2740 visitor.variables.type = compiler.types.dynamicType; 2740 visitor.variables.type = compiler.types.dynamicType;
2741 } 2741 }
2742 2742
2743 Modifiers modifiers = node.modifiers; 2743 Modifiers modifiers = node.modifiers;
2744 void reportExtraModifier(String modifier) { 2744 void reportExtraModifier(String modifier) {
2745 Node modifierNode; 2745 Node modifierNode;
2746 for (var nodes = modifiers.nodes; !nodes.isEmpty; nodes = nodes.tail) { 2746 for (Link<Node> nodes = modifiers.nodes.nodes;
2747 !nodes.isEmpty;
2748 nodes = nodes.tail) {
2747 if (modifier == nodes.head.asIdentifier().source.stringValue) { 2749 if (modifier == nodes.head.asIdentifier().source.stringValue) {
2748 modifierNode = nodes.head; 2750 modifierNode = nodes.head;
2749 break; 2751 break;
2750 } 2752 }
2751 } 2753 }
2752 assert(modifierNode != null); 2754 assert(modifierNode != null);
2753 compiler.reportError(modifierNode, MessageKind.EXTRANEOUS_MODIFIER, 2755 compiler.reportError(modifierNode, MessageKind.EXTRANEOUS_MODIFIER,
2754 {'modifier': modifier}); 2756 {'modifier': modifier});
2755 } 2757 }
2756 if (modifiers.isFinal() && (modifiers.isConst() || modifiers.isVar())) { 2758 if (modifiers.isFinal() && (modifiers.isConst() || modifiers.isVar())) {
2757 reportExtraModifier('final'); 2759 reportExtraModifier('final');
2758 } 2760 }
2759 if (modifiers.isVar() && (modifiers.isConst() || node.type != null)) { 2761 if (modifiers.isVar() && (modifiers.isConst() || node.type != null)) {
2760 reportExtraModifier('var'); 2762 reportExtraModifier('var');
2761 } 2763 }
2762 2764 if (enclosingElement.isFunction()) {
2765 if (modifiers.isAbstract()) {
2766 reportExtraModifier('abstract');
2767 }
2768 if (modifiers.isStatic()) {
2769 reportExtraModifier('static');
2770 }
2771 }
2763 visitor.visit(node.definitions); 2772 visitor.visit(node.definitions);
2764 } 2773 }
2765 2774
2766 visitWhile(While node) { 2775 visitWhile(While node) {
2767 visit(node.condition); 2776 visit(node.condition);
2768 visitLoopBodyIn(node, node.body, new BlockScope(scope)); 2777 visitLoopBodyIn(node, node.body, new BlockScope(scope));
2769 } 2778 }
2770 2779
2771 visitParenthesizedExpression(ParenthesizedExpression node) { 2780 visitParenthesizedExpression(ParenthesizedExpression node) {
2772 bool oldSendIsMemberAccess = sendIsMemberAccess; 2781 bool oldSendIsMemberAccess = sendIsMemberAccess;
(...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after
4411 return e; 4420 return e;
4412 } 4421 }
4413 4422
4414 /// Assumed to be called by [resolveRedirectingFactory]. 4423 /// Assumed to be called by [resolveRedirectingFactory].
4415 Element visitReturn(Return node) { 4424 Element visitReturn(Return node) {
4416 Node expression = node.expression; 4425 Node expression = node.expression;
4417 return finishConstructorReference(visit(expression), 4426 return finishConstructorReference(visit(expression),
4418 expression, expression); 4427 expression, expression);
4419 } 4428 }
4420 } 4429 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/scanner/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698