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

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

Issue 21513005: Report ASSIGNMENT_TO_CONST. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 5 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 33eb4dda9ac28338abf2f5252d015fc9c8bc8c76..a31fc36ebbb6695ae2dd9fd5602372dfc2c0cadd 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
@@ -1741,11 +1741,12 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
*
* @param node the expression to evaluate
* @return {@code true} if and only if an error code is generated on the passed node
+ * @see StaticWarningCode#ASSIGNMENT_TO_CONST
* @see StaticWarningCode#ASSIGNMENT_TO_FINAL
* @see StaticWarningCode#ASSIGNMENT_TO_METHOD
*/
private boolean checkForAssignmentToFinal(Expression expression) {
- // prepare LHS element
+ // prepare element
Element element = null;
if (expression instanceof Identifier) {
element = ((Identifier) expression).getElement();
@@ -1753,18 +1754,18 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
if (expression instanceof PropertyAccess) {
element = ((PropertyAccess) expression).getPropertyName().getElement();
}
- // check if LHS is assignable
+ // check if element is assignable
+ if (element instanceof PropertyAccessorElement) {
+ PropertyAccessorElement accessor = (PropertyAccessorElement) element;
+ element = accessor.getVariable();
+ }
if (element instanceof VariableElement) {
- VariableElement leftVar = (VariableElement) element;
- if (leftVar.isFinal()) {
- errorReporter.reportError(StaticWarningCode.ASSIGNMENT_TO_FINAL, expression);
+ VariableElement variable = (VariableElement) element;
+ if (variable.isConst()) {
+ errorReporter.reportError(StaticWarningCode.ASSIGNMENT_TO_CONST, expression);
return true;
}
- return false;
- }
- if (element instanceof PropertyAccessorElement) {
- PropertyAccessorElement leftAccessor = (PropertyAccessorElement) element;
- if (!leftAccessor.isSetter()) {
+ if (variable.isFinal()) {
errorReporter.reportError(StaticWarningCode.ASSIGNMENT_TO_FINAL, expression);
return true;
}

Powered by Google App Engine
This is Rietveld 408576698