File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -2165,6 +2165,10 @@ rb_class_superclass(VALUE klass)
2165
2165
if (klass == rb_cBasicObject ) return Qnil ;
2166
2166
rb_raise (rb_eTypeError , "uninitialized class" );
2167
2167
}
2168
+
2169
+ if (!RCLASS_SUPERCLASS_DEPTH (klass )) {
2170
+ return Qnil ;
2171
+ }
2168
2172
else {
2169
2173
super = RCLASS_SUPERCLASSES (klass )[RCLASS_SUPERCLASS_DEPTH (klass ) - 1 ];
2170
2174
RUBY_ASSERT (RB_TYPE_P (klass , T_CLASS ));
Original file line number Diff line number Diff line change @@ -96,6 +96,13 @@ def test_instantiate_singleton_class
96
96
97
97
def test_superclass_of_basicobject
98
98
assert_equal ( nil , BasicObject . superclass )
99
+
100
+ assert_separately ( [ ] , "#{ <<~"begin;" } \n #{ <<~'end;' } " )
101
+ begin;
102
+ module Mod end
103
+ BasicObject.include(Mod)
104
+ assert_equal(nil, BasicObject.superclass)
105
+ end;
99
106
end
100
107
101
108
def test_module_function
You can’t perform that action at this time.
0 commit comments