-
-
Save headius/204a219637e900a08c16 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/core/src/main/java/org/jruby/RubyModule.java b/core/src/main/java/org/jruby/RubyModule.java | |
index 71fbb4a..b77a5cf 100644 | |
--- a/core/src/main/java/org/jruby/RubyModule.java | |
+++ b/core/src/main/java/org/jruby/RubyModule.java | |
@@ -483,6 +483,9 @@ public class RubyModule extends RubyObject { | |
// First, we count the parents | |
int parentCount = 0; | |
for (RubyModule p = getParent() ; p != null && p != objectClass ; p = p.getParent()) { | |
+ // Break out of cyclic namespaces like C::A = C2; C2::A = C (jruby/jruby#2314) | |
+ if (p == this) break; | |
+ | |
parentCount++; | |
} | |
@@ -491,6 +494,9 @@ public class RubyModule extends RubyObject { | |
int i = parentCount - 1; | |
int totalLength = name.length() + parentCount * 2; // name length + enough :: for all parents | |
for (RubyModule p = getParent() ; p != null && p != objectClass ; p = p.getParent(), i--) { | |
+ // Break out of cyclic namespaces like C::A = C2; C2::A = C (jruby/jruby#2314) | |
+ if (p == this) break; | |
+ | |
String pName = p.getBaseName(); | |
// This is needed when the enclosing class or module is a singleton. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment