Skip to content

Commit f51a112

Browse files
committed
Don't search Object from BasicObject children
The final Object search should not be done when the target class descends from BasicObject instead of Object. We test this by checking its allocator against the default RubyBasicObject allocator.
1 parent 1de2b8a commit f51a112

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

core/src/main/java/org/jruby/RubyModule.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4835,8 +4835,11 @@ public IRubyObject getConstantNoConstMissingSKipAutoload(String name) {
48354835
private IRubyObject getConstantSkipAutoload(String name, boolean inherit, boolean searchObject, boolean inheritObject) {
48364836
IRubyObject constant = iterateConstantNoConstMissing(name, this, inherit, false, inheritObject);
48374837

4838-
if (constant == null && searchObject) {
4839-
constant = iterateConstantNoConstMissing(name, getRuntime().getObject(), inherit, false, true);
4838+
Ruby runtime = getRuntime();
4839+
4840+
// only search object if specified and this module is a class and does not extend from BasicObject
4841+
if (constant == null && searchObject && (!(this instanceof RubyClass) || ((RubyClass) this).getAllocator() != BASICOBJECT_ALLOCATOR)) {
4842+
constant = iterateConstantNoConstMissing(name, runtime.getObject(), inherit, false, true);
48404843
}
48414844

48424845
return constant;

0 commit comments

Comments
 (0)