Skip to content

.singleton_methods returns an empty array after prepending #5799

@flash-gordon

Description

@flash-gordon

Environment

$ jruby -v
jruby 9.2.6.0 (2.5.3) 2019-02-11 15ba00b Java HotSpot(TM) 64-Bit Server VM 25.201-b09 on 1.8.0_201-b09 +jit [darwin-x86_64]
$ uname -a
Darwin Nikitas-MacBook-Pro.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64

Expected Behavior

CRuby 2.6.3:

obj = Object.new

def obj.foo
end

p obj.singleton_methods(false) # => [:foo]
obj.singleton_class.prepend(Module.new)
p obj.singleton_methods(false) # => [:foo]

Actual Behavior

JRuby:

obj = Object.new

def obj.foo
end

p obj.singleton_methods(false) # => [:foo]
obj.singleton_class.prepend(Module.new)
p obj.singleton_methods(false) # => []

I'm going to use obj.singleton_class.instance_methods(false), it works fine in both cases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions