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

Unified Diff: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java

Issue 8467017: Fix for cyclic declaration, issue 348 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
diff --git a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
index 01a22af775c22306ddc3ef7b42198abf51a88ee8..17f1d83f5f87639ef053ee3d5a2031ba44f32502 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -1470,14 +1470,20 @@ public class TypeAnalyzer implements DartCompilationPhase {
@Override
public Void visitClass(DartClass node) {
assert node.getSymbol().getType() == currentClass;
+
+ // Prepare supertypes - all superclasses and interfaces.
List<InterfaceType> supertypes = Collections.emptyList();
+ boolean hasCyclicDeclaration = false;
try {
supertypes = currentClass.getElement().getAllSupertypes();
} catch (CyclicDeclarationException e) {
// Already reported by resolver.
+ hasCyclicDeclaration = true;
} catch (DuplicatedInterfaceException e) {
// Already reported by resolver.
}
+
+ // Add all super members to resolve.
EnclosingElement currentLibrary = currentClass.getElement().getEnclosingElement();
for (InterfaceType supertype : supertypes) {
for (Element member : supertype.getElement().getMembers()) {
@@ -1490,10 +1496,21 @@ public class TypeAnalyzer implements DartCompilationPhase {
superMembers.put(name, member);
}
}
+
+ // Visit members, so resolve methods declared in this class.
this.visit(node.getMembers());
+
+ // If interface, we don't care about unimplemented methods.
if (currentClass.getElement().isInterface()) {
return null;
}
+
+ // If we have cyclic declaration, hierarchy is broken, no reason to report unimplemented.
+ if (hasCyclicDeclaration) {
+ return null;
+ }
+
+ // Visit superclasses (without interfaces) and mark methods as implemented.
InterfaceType supertype = currentClass.getElement().getSupertype();
while (supertype != null) {
ClassElement superclass = supertype.getElement();
@@ -1502,6 +1519,8 @@ public class TypeAnalyzer implements DartCompilationPhase {
}
supertype = supertype.getElement().getSupertype();
}
+
+ // All remaining methods are unimplemented.
for (String name : superMembers.keys()) {
Collection<Element> elements = superMembers.removeAll(name);
for (Element element : elements) {
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698