Skip to content

Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →

class method

ObjectSpace.internal_super_of

(untyped) -> untyped
ObjectSpace.internal_super_of(cls) → class or module

Returns the immediate superclass of cls, including any hidden class such as an included module’s iclass.

Unlike Class#superclass, this does not skip over the iclasses that Ruby inserts for included modules:

Example
require 'objspace'

module M; end
class A; include M; end
A.superclass                       # => Object
ObjectSpace.internal_super_of(A)   # => #<InternalObject:0x... T_ICLASS>

cls must be a Class or Module, or an ObjectSpace::InternalObjectWrapper that wraps one.

Note that you should not use this method in your application.

This method is only expected to work with C Ruby.