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

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

Issue 14698003: Report CTEC.MULTIPLE_SUPER_INITIALIZERS (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 fd7ad6e3b7bf2b2150a60c9d9b37a6df8a6e2fbf..3704b4eeac483296640268df96771d3c9e501b58 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
@@ -55,6 +55,7 @@ import com.google.dart.engine.ast.ReturnStatement;
import com.google.dart.engine.ast.SimpleFormalParameter;
import com.google.dart.engine.ast.SimpleIdentifier;
import com.google.dart.engine.ast.Statement;
+import com.google.dart.engine.ast.SuperConstructorInvocation;
import com.google.dart.engine.ast.SwitchCase;
import com.google.dart.engine.ast.SwitchMember;
import com.google.dart.engine.ast.SwitchStatement;
@@ -298,6 +299,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
checkForConstConstructorWithNonFinalField(node);
checkForConflictingConstructorNameAndMember(node);
checkForAllFinalInitializedErrorCodes(node);
+ checkForMultipleSuperInitializers(node);
return super.visitConstructorDeclaration(node);
} finally {
isEnclosingConstructorConst = false;
@@ -1414,6 +1416,26 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
}
/**
+ * This verifies that the passed constructor has at most one 'super' initializer.
+ *
+ * @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#MULTIPLE_SUPER_INITIALIZERS
+ */
+ private boolean checkForMultipleSuperInitializers(ConstructorDeclaration node) {
+ int numSuperInitializers = 0;
+ for (ConstructorInitializer initializer : node.getInitializers()) {
+ if (initializer instanceof SuperConstructorInvocation) {
+ numSuperInitializers++;
+ if (numSuperInitializers > 1) {
+ errorReporter.reportError(CompileTimeErrorCode.MULTIPLE_SUPER_INITIALIZERS, initializer);
+ }
+ }
+ }
+ return numSuperInitializers > 0;
+ }
+
+ /**
* Checks to ensure that native function bodies can only in SDK code.
*
* @param node the native function body to test

Powered by Google App Engine
This is Rietveld 408576698