Skip to content

Commit 836cfd4

Browse files
authored
Merge pull request jruby#9031 from headius/also_search_object_for_classes
Don't restrict object search to modules
2 parents dcca34d + f51a112 commit 836cfd4

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 && !isClass() && 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)