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

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

Issue 9689086: Fixes cyclic constructor issue in dartc (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | frog/tests/leg_only/src/CyclicConstructorTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/resolver/Resolver.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/Resolver.java b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
index 38f69f54700f1145f62b99bedf03dec4f287aa59..0d768a63fb72bd279bf46fb3b98c1b2b4c78ad3b 100644
--- a/compiler/java/com/google/dart/compiler/resolver/Resolver.java
+++ b/compiler/java/com/google/dart/compiler/resolver/Resolver.java
@@ -72,6 +72,7 @@ import com.google.dart.compiler.type.TypeVariable;
import com.google.dart.compiler.util.StringUtils;
import java.util.EnumSet;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@@ -1817,16 +1818,21 @@ public class Resolver {
}
private boolean hasRedirectedConstructorCycle(ConstructorElement constructorElement) {
+ HashSet<ConstructorElement> visited = new HashSet<ConstructorElement>();
ConstructorElement next = getNextConstructorInvocation(constructorElement);
while (next != null) {
+ if (visited.contains(next)) {
+ return true;
+ }
if (constructorElement.getName().equals(next.getName())) {
return true;
}
+ visited.add(next);
next = getNextConstructorInvocation(next);
}
return false;
}
-
+
private ConstructorElement getNextConstructorInvocation(ConstructorElement constructor) {
List<DartInitializer> inits = ((DartMethodDefinition) constructor.getNode()).getInitializers();
// The parser ensures that redirected constructors can be the only item in the initialization
« no previous file with comments | « no previous file | frog/tests/leg_only/src/CyclicConstructorTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698