Index: compiler/java/com/google/dart/compiler/resolver/ClassScope.java |
=================================================================== |
--- compiler/java/com/google/dart/compiler/resolver/ClassScope.java (revision 8661) |
+++ compiler/java/com/google/dart/compiler/resolver/ClassScope.java (working copy) |
@@ -6,6 +6,9 @@ |
import com.google.dart.compiler.type.InterfaceType; |
+import java.util.HashSet; |
+import java.util.Set; |
+ |
/** |
* Lexical scope corresponding to a class body. |
*/ |
@@ -24,18 +27,23 @@ |
@Override |
public Element findElement(LibraryElement inLibrary, String name) { |
+ return findElement(inLibrary, name, new HashSet<ClassElement>()); |
+ } |
+ |
+ protected Element findElement(LibraryElement inLibrary, String name, Set<ClassElement> examinedTypes) { |
Element element = super.findElement(inLibrary, name); |
if (element != null) { |
return element; |
} |
+ examinedTypes.add(classElement); |
InterfaceType superclass = classElement.getSupertype(); |
if (superclass != null) { |
Element enclosing = superclass.getElement().getEnclosingElement(); |
ClassElement superclassElement = superclass.getElement(); |
- if (superclassElement != classElement) { |
+ if (!examinedTypes.contains(superclassElement)) { |
ClassScope scope = new ClassScope(superclassElement, |
new Scope("library", (LibraryElement) enclosing)); |
- element = scope.findElement(inLibrary, name); |
+ element = scope.findElement(inLibrary, name, examinedTypes); |
switch (ElementKind.of(element)) { |
case TYPE_VARIABLE: |
return null; |
@@ -49,10 +57,10 @@ |
for (InterfaceType supertype : classElement.getInterfaces()) { |
Element enclosing = supertype.getElement().getEnclosingElement(); |
ClassElement superclassElement = supertype.getElement(); |
- if (superclassElement != classElement) { |
+ if (!examinedTypes.contains(superclassElement)) { |
ClassScope scope = new ClassScope(superclassElement, |
new Scope("library", (LibraryElement) enclosing)); |
- element = scope.findElement(inLibrary, name); |
+ element = scope.findElement(inLibrary, name, examinedTypes); |
if (element != null) { |
return element; |
} |