1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/irb] Fix error on ls object_cant_define_singleton

such as `ls 42`, `ls :sym` and so on

b1d436a853
This commit is contained in:
Masataka Pocke Kuwabara 2021-06-29 19:16:58 +09:00 committed by git
parent 0feec79846
commit e8c2b03ee1
2 changed files with 22 additions and 2 deletions

View file

@ -24,9 +24,10 @@ module IRB
end
def dump_methods(o, klass, obj)
maps = class_method_map(obj.singleton_class.ancestors)
singleton_class = obj.singleton_class rescue nil
maps = class_method_map((singleton_class || klass).ancestors)
maps.each do |mod, methods|
name = mod == obj.singleton_class ? "#{klass}.methods" : "#{mod}#methods"
name = mod == singleton_class ? "#{klass}.methods" : "#{mod}#methods"
o.dump(name, methods)
end
end