Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.singleton_methods returns an empty array after prepending #5799

Closed
flash-gordon opened this issue Jul 24, 2019 · 3 comments

Comments

@flash-gordon
Copy link

commented Jul 24, 2019

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.

flash-gordon added a commit to dry-rb/dry-monads that referenced this issue Jul 24, 2019

@flash-gordon

This comment has been minimized.

Copy link
Author

commented Jul 24, 2019

Ran on 9.2.7.0, same incorrect output.

@headius

This comment has been minimized.

Copy link
Member

commented Jul 29, 2019

Confirmed on master.

@headius headius added this to the JRuby 9.2.8.0 milestone Jul 29, 2019

@headius

This comment has been minimized.

Copy link
Member

commented Jul 29, 2019

Fixed in abc3fbf.

I did not find any tests for exactly this behavior in either the CRuby test suite or in ruby/spec. Could you add one to the singleton_methods spec via PR? Thanks for the report!

@headius headius closed this Jul 29, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.