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

Unified Diff: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java

Issue 14761016: Report CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
index ab69d17a64973804be7a11ba42e7529d41c44aa0..567b5d53eff6af58e2c994d56c36df996b6a29a1 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/verifier/ErrorVerifier.java
@@ -466,6 +466,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
}
}
}
+ checkForNonConstMapAsExpressionStatement(node);
return super.visitMapLiteral(node);
}
@@ -1758,6 +1759,32 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
}
/**
+ * This verifies the passed map literal either:
+ * <ul>
+ * <li>has {@code const modifier}</li>
+ * <li>has explicit type arguments</li>
+ * <li>is not expression of the expression statement</li>
+ * <ul>
+ *
+ * @param node the map literal to evaluate
+ * @return {@code true} if and only if an error code is generated on the passed node
+ * @see CompileTimeErrorCode#NON_CONST_MAP_AS_EXPRESSION_STATEMENT
+ */
+ private boolean checkForNonConstMapAsExpressionStatement(MapLiteral node) {
+ if (node.getModifier() != null) {
+ return false;
+ }
+ if (node.getTypeArguments() != null) {
+ return false;
+ }
+ if (!(node.getParent() instanceof ExpressionStatement)) {
+ return false;
+ }
+ errorReporter.reportError(CompileTimeErrorCode.NON_CONST_MAP_AS_EXPRESSION_STATEMENT, node);
+ return true;
+ }
+
+ /**
* This verifies the passed method declaration of operator {@code []=}, has {@code void} return
* type.
*

Powered by Google App Engine
This is Rietveld 408576698