-
-
Notifications
You must be signed in to change notification settings - Fork 925
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
Changing method visibility changes method ownership, but doesn't on MRI #2565
Comments
@headius The following it 'uses the method signature from `#initialize` for arg verification' do
# Commented it out and it still passes ❤️
# pending "Failing on JRuby due to https://github.com/jruby/jruby/issues/2565" if RSpec::Support::Ruby.jruby?
subclass = Class.new(klass) do
private_class_method :new
end
prevents(/arguments/) { allow(subclass).to receive(:new).with(1) }
allow(subclass).to receive(:new).with(1, 2)
end Also, as reported originally: $ ruby --version
jruby 9.2.13.0 (2.5.7) 2020-08-03 9a89c94bcc OpenJDK 64-Bit Server VM 14.0.1+14 on 14.0.1+14 +jit [darwin-x86_64]
$ ruby -e "class A; private_class_method :new; end; puts A.method(:new).owner"
Class
$ ruby -e "class A; private :inspect; end; puts A.instance_method(:inspect).owner"
Kernel This seems to have been fixed, so I guess this issue can be closed. Thanks! |
Thanks for the update! This was probably fixed when we reworked how method tables function to better support unusual |
FWIW, I think the behavior is actually a CRuby bug: https://bugs.ruby-lang.org/issues/18729 |
I think you meant to link to https://bugs.ruby-lang.org/issues/18729. |
Oops, indeed, I edited my comment. |
I'm noticing that when you change method visibility on JRuby, it has a side effect that's not present on MRI: it changes what
Method#owner
returns.First, here's the behavior on MRI 2.2:
It looks like this has always been MRI's behavior; on 1.8.7 I see the same thing:
Compare that to JRuby's behavior:
The text was updated successfully, but these errors were encountered: