-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
Environment
I've tested this on 9.1.16.0 and the latest master.
# bin/jruby --version
jruby 9.2.0.0-SNAPSHOT (2.4.1) 2018-03-04 b75044c Java HotSpot(TM) 64-Bit Server VM 25.31-b07 on 1.8.0_31-b13 +jit [darwin-x86_64]
# bin/jruby --version
jruby 9.1.16.0 (2.3.3) 2018-03-04 8f3f95a Java HotSpot(TM) 64-Bit Server VM 25.31-b07 on 1.8.0_31-b13 +jit [darwin-x86_64]
Expected Behavior
Given the following code, I'd expect a method's owner to be equal to the class where the method is defined.
class FakeClass
prepender = Module.new
prepend prepender
def fake_method
end
alias_method :other_fake_method, :fake_method
endBoth of these lines should return true:
FakeClass.instance_method(:fake_method).owner == FakeClass
FakeClass.instance_method(:other_fake_method).owner == FakeClassActual Behavior
The second line returns false:
irb(main):014:0> FakeClass.instance_method(:fake_method).owner == FakeClass
=> true
irb(main):015:0> FakeClass.instance_method(:other_fake_method).owner == FakeClass
=> false
I think it's because the owner of the aliased method doesn't include the prepended module:
irb(main):012:0* FakeClass.instance_method(:fake_method).owner.ancestors
=> [#<Module:0x32464a14>, FakeClass, Object, Kernel, BasicObject]
irb(main):013:0> FakeClass.instance_method(:other_fake_method).owner.ancestors
=> [FakeClass, Object, Kernel, BasicObject]
I've also tested this on MRI 2.3.1 and 2.4.3 and they behave as expected.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels