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

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

Issue 15409004: Update CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD to check also super/mixin types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move hasNonFinalField() to ClassElement 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 db0c4fc54c3c72c1cff5beac3d9e2520a6128b0c..0fc30fe12a34a2ff11ff805d67d2a0385c0f2010 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
@@ -1352,10 +1352,10 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
}
/**
- * This verifies that the passed constructor declaration is not 'const' if it has a non-final
+ * This verifies that the passed constructor declaration is 'const' then there are no non-final
* instance variable.
*
- * @param node the instance creation expression to evaluate
+ * @param node the constructor declaration to evaluate
* @return {@code true} if and only if an error code is generated on the passed node
* @see CompileTimeErrorCode#CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD
*/
@@ -1363,20 +1363,15 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
if (!isEnclosingConstructorConst) {
return false;
}
+ // check if there is non-final field
ConstructorElement constructorElement = node.getElement();
- if (constructorElement != null) {
- ClassElement classElement = constructorElement.getEnclosingElement();
- FieldElement[] elements = classElement.getFields();
- for (FieldElement field : elements) {
- if (!field.isFinal() && !field.isConst() && !field.isStatic() && !field.isSynthetic()) {
- errorReporter.reportError(
- CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD,
- node);
- return true;
- }
- }
+ ClassElement classElement = constructorElement.getEnclosingElement();
+ if (!classElement.hasNonFinalField()) {
+ return false;
}
- return false;
+ // report problem
+ errorReporter.reportError(CompileTimeErrorCode.CONST_CONSTRUCTOR_WITH_NON_FINAL_FIELD, node);
+ return true;
}
/**

Powered by Google App Engine
This is Rietveld 408576698