diff --git a/lib/zeitwerk/real_mod_name.rb b/lib/zeitwerk/real_mod_name.rb index 430fa99..d266f5e 100644 --- a/lib/zeitwerk/real_mod_name.rb +++ b/lib/zeitwerk/real_mod_name.rb @@ -10,7 +10,18 @@ module Zeitwerk::RealModName # The name method can be overridden, hence the indirection in this method. # # @sig (Module) -> String? - def real_mod_name(mod) - UNBOUND_METHOD_MODULE_NAME.bind_call(mod) + if RUBY_ENGINE == 'truffleruby' && (RUBY_ENGINE_VERSION.split('.').map(&:to_i) <=> [24, 2, 0]) < 0 + def real_mod_name(mod) + name = UNBOUND_METHOD_MODULE_NAME.bind_call(mod) + # https://github.com/oracle/truffleruby/issues/3683 + if name && name.start_with?('Object::') + name = name[8..-1] + end + name + end + else + def real_mod_name(mod) + UNBOUND_METHOD_MODULE_NAME.bind_call(mod) + end end end