Project

General

Profile

Actions

Bug #16106

closed

UnboundMethod owner points to base class

Added by sbellware (Scott Bellware) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]
[ruby-core:94372]

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

unbound_method_owner_sketch.rb (176 Bytes) unbound_method_owner_sketch.rb sbellware (Scott Bellware), 08/15/2019 08:17 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0