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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/SupertypeResolver.java

Issue 10918247: Issue 5084. Report error if a type name appears multiple times in an implements clause (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Don't report duplicates for unresolved types Created 8 years, 3 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: compiler/java/com/google/dart/compiler/resolver/SupertypeResolver.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/SupertypeResolver.java b/compiler/java/com/google/dart/compiler/resolver/SupertypeResolver.java
index fa461d5ccd4c29a1e7e9b4de62cfc028bd6665ad..a1819b9d45d095bf02d9fca90832c9197f8a87c7 100644
--- a/compiler/java/com/google/dart/compiler/resolver/SupertypeResolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/SupertypeResolver.java
@@ -5,6 +5,7 @@
package com.google.dart.compiler.resolver;
import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Sets;
import com.google.dart.compiler.DartCompilerContext;
import com.google.dart.compiler.ast.ASTVisitor;
import com.google.dart.compiler.ast.DartClass;
@@ -91,19 +92,29 @@ public class SupertypeResolver {
}
if (node.getInterfaces() != null) {
+ Set<InterfaceType> seenImplement = Sets.newHashSet();
for (DartTypeNode intNode : node.getInterfaces()) {
- InterfaceType intElement = classContext.resolveInterface(intNode, false, false);
- Elements.addInterface(classElement, intElement);
- // Dynamic can not be used as interface.
+ InterfaceType intType = classContext.resolveInterface(intNode, false, false);
+ // May be type which can not be used as interface.
if (Elements.isTypeNode(intNode, BLACK_LISTED_TYPES)
&& !Elements.isCoreLibrarySource(node.getSourceInfo().getSource())) {
topLevelContext.onError(intNode, ResolverErrorCode.BLACK_LISTED_IMPLEMENTS, intNode);
continue;
}
// May be unresolved type, error already reported, ignore.
- if (intElement.getKind() == TypeKind.DYNAMIC) {
+ if (intType.getKind() == TypeKind.DYNAMIC) {
continue;
}
+ // check for uniqueness
+ if (!classElement.isInterface()) {
+ if (seenImplement.contains(intType)) {
+ topLevelContext.onError(intNode, ResolverErrorCode.DUPLICATE_IMPLEMENTS_TYPE);
+ continue;
+ }
+ seenImplement.add(intType);
+ }
+ // OK, add
+ Elements.addInterface(classElement, intType);
}
}
setBoundsOnTypeParameters(classElement.getTypeParameters(), classContext);

Powered by Google App Engine
This is Rietveld 408576698