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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/Resolver.java

Issue 10854106: Issue 4347. Report error if ++/-- is applied to final variable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/resolver/Resolver.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/Resolver.java b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
index 5b26cab03bcb458f0332be832d2d66a7b37af600..46e5953b134296a849f293782b1a23addb81db61 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Resolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
@@ -62,6 +62,7 @@ import com.google.dart.compiler.ast.DartTryStatement;
import com.google.dart.compiler.ast.DartTypeExpression;
import com.google.dart.compiler.ast.DartTypeNode;
import com.google.dart.compiler.ast.DartTypeParameter;
+import com.google.dart.compiler.ast.DartUnaryExpression;
import com.google.dart.compiler.ast.DartUnit;
import com.google.dart.compiler.ast.DartUnqualifiedInvocation;
import com.google.dart.compiler.ast.DartVariable;
@@ -1877,6 +1878,25 @@ public class Resolver {
}
@Override
+ public Element visitUnaryExpression(DartUnaryExpression node) {
+ DartExpression arg = node.getArg();
+ Element argElement = resolve(arg);
+ if (node.getOperator().isCountOperator()) {
+ switch (ElementKind.of(argElement)) {
+ case FIELD:
+ case PARAMETER:
+ case VARIABLE:
+ if (argElement.getModifiers().isFinal()) {
+ topLevelContext.onError(arg, ResolverErrorCode.CANNOT_ASSIGN_TO_FINAL,
+ argElement.getName());
+ }
+ break;
+ }
+ }
+ return null;
+ }
+
+ @Override
public Element visitMapLiteral(DartMapLiteral node) {
List<DartTypeNode> originalTypeArgs = node.getTypeArguments();
List<DartTypeNode> typeArgs = Lists.newArrayList();
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/resolver/NegativeResolverTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698