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

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

Issue 18808002: Report IMPLEMENTS_SUPER_CLASS (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Test for implicit Object superclass 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 c8941ec74ca37029f0c1378d682599f27fd35e1d..93a052dac8a9036fc70d4f8a97a65b73c4626701 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
@@ -431,6 +431,7 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
checkForFinalNotInitialized(node);
checkForDuplicateDefinitionInheritance();
checkForConflictingGetterAndMethod();
+ checkImplementsSuperClass(node);
return super.visitClassDeclaration(node);
} finally {
initialFieldElementsMap = null;
@@ -4296,6 +4297,39 @@ public class ErrorVerifier extends RecursiveASTVisitor<Void> {
}
/**
+ * This verifies that the given class declaration does not have the same class in the 'extends'
+ * and 'implements' clauses.
+ *
+ * @return {@code true} if and only if an error code is generated on the passed node
+ * @see CompileTimeErrorCode#IMPLEMENTS_SUPER_CLASS
+ */
+ private boolean checkImplementsSuperClass(ClassDeclaration node) {
+ // prepare super type
+ InterfaceType superType = enclosingClass.getSupertype();
+ if (superType == null) {
+ return false;
+ }
+ // prepare interfaces
+ ImplementsClause implementsClause = node.getImplementsClause();
+ if (implementsClause == null) {
+ return false;
+ }
+ // check interfaces
+ boolean hasProblem = false;
+ for (TypeName interfaceNode : implementsClause.getInterfaces()) {
+ if (interfaceNode.getType().equals(superType)) {
+ hasProblem = true;
+ errorReporter.reportError(
+ CompileTimeErrorCode.IMPLEMENTS_SUPER_CLASS,
+ interfaceNode,
+ superType.getDisplayName());
+ }
+ }
+ // done
+ return hasProblem;
+ }
+
+ /**
* Return the propagated type of the given expression, or the static type if there is no
* propagated type information.
*

Powered by Google App Engine
This is Rietveld 408576698