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

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

Issue 10627017: Removes compile-time error from implementing the same interface more than once (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 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/ClassElementImplementation.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java b/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java
index bab38963c55c3818c42d336fa54b4731af962687..5d2d93fdb71c54ee14b61d1ed43c97012f8b65f0 100644
--- a/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java
+++ b/compiler/java/com/google/dart/compiler/resolver/ClassElementImplementation.java
@@ -75,7 +75,7 @@ class ClassElementImplementation extends AbstractNodeElement implements ClassNod
public DartDeclaration<?> getNode() {
return (DartClass) super.getNode();
}
-
+
@Override
public SourceInfo getNameLocation() {
return nameLocation;
@@ -170,7 +170,7 @@ class ClassElementImplementation extends AbstractNodeElement implements ClassNod
public String getNativeName() {
return nativeName;
}
-
+
@Override
public String getDeclarationNameWithTypeParameters() {
return declarationNameWithTypeParameter;
@@ -295,7 +295,7 @@ class ClassElementImplementation extends AbstractNodeElement implements ClassNod
@Override
public List<InterfaceType> getAllSupertypes()
- throws CyclicDeclarationException, DuplicatedInterfaceException {
+ throws CyclicDeclarationException {
List<InterfaceType> list = allSupertypes.get();
if (list == null) {
allSupertypes.compareAndSet(null, computeAllSupertypes());
@@ -305,7 +305,7 @@ class ClassElementImplementation extends AbstractNodeElement implements ClassNod
}
private List<InterfaceType> computeAllSupertypes()
- throws CyclicDeclarationException, DuplicatedInterfaceException {
+ throws CyclicDeclarationException {
Map<ClassElement, InterfaceType> interfaces = new HashMap<ClassElement, InterfaceType>();
if (!seenSupertypes.get().add(this)) {
throw new CyclicDeclarationException(this);
@@ -313,12 +313,12 @@ class ClassElementImplementation extends AbstractNodeElement implements ClassNod
ArrayList<InterfaceType> supertypes = new ArrayList<InterfaceType>();
try {
for (InterfaceType intf : getInterfaces()) {
- addCheckDuplicated(interfaces, supertypes, intf);
+ addInterfaceToSupertypes(interfaces, supertypes, intf);
}
for (InterfaceType intf : getInterfaces()) {
for (InterfaceType t : intf.getElement().getAllSupertypes()) {
if (!t.getElement().isObject()) {
- addCheckDuplicated(interfaces, supertypes,
+ addInterfaceToSupertypes(interfaces, supertypes,
t.subst(intf.getArguments(),
intf.getElement().getTypeParameters()));
}
@@ -327,7 +327,7 @@ class ClassElementImplementation extends AbstractNodeElement implements ClassNod
if (supertype != null) {
for (InterfaceType t : supertype.getElement().getAllSupertypes()) {
if (t.getElement().isInterface()) {
- addCheckDuplicated(interfaces, supertypes,
+ addInterfaceToSupertypes(interfaces, supertypes,
t.subst(supertype.getArguments(),
supertype.getElement().getTypeParameters()));
}
@@ -346,24 +346,20 @@ class ClassElementImplementation extends AbstractNodeElement implements ClassNod
return supertypes;
}
- private void addCheckDuplicated(Map<ClassElement, InterfaceType> interfaces,
+ private void addInterfaceToSupertypes(Map<ClassElement, InterfaceType> interfaces,
ArrayList<InterfaceType> supertypes,
- InterfaceType intf) throws DuplicatedInterfaceException {
+ InterfaceType intf) {
InterfaceType existing = interfaces.put(intf.getElement(), intf);
- if (existing == null) {
+ if (existing == null || !(existing.equals(intf))){
supertypes.add(intf);
- } else {
- if (!existing.equals(intf)) {
- throw new DuplicatedInterfaceException(existing, intf);
- }
}
}
-
+
@Override
public List<Element> getUnimplementedMembers() {
return unimplementedMembers;
}
-
+
@Override
public void setUnimplementedMembers(List<Element> members) {
this.unimplementedMembers = members;

Powered by Google App Engine
This is Rietveld 408576698