Actions
Bug #16106
closedUnboundMethod owner points to base class
Bug #16106:
UnboundMethod owner points to base class
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]
Backport:
Description
This may not be a bug. It may be my misinterpretation of the feature.
When using UnboundMethod#owner on a class that was created with Class.new(SomeBaseClass)
, the owner is reported as the SomeBaseClass
rather than the new class.
This was a surprising outcome, since I presumed that the owner method would point to the class rather than the class's base class.
Example:
class SomeClass
def some_method
end
end
C = Class.new(SomeClass)
m = C.instance_method(:some_method)
pp m.owner
# => SomeClass
# I would have expected the owner to be C
Is this expected behavior?
Thanks,
Scott
Files
Actions