Issue #16106 has been updated by Eregon (Benoit Daloze).


An interesting bit here is that there is no way to get back the module from which the method was retrieved, even though it's shown in #inspect:
```
> Range.instance_method :map
=> #<UnboundMethod: Range(Enumerable)#map>
```

Maybe we should expose `UnboundMethod#origin`? That would be a separate feature request, though.

----------------------------------------
Bug #16106: UnboundMethod owner points to base class
https://bugs.ruby-lang.org/issues/16106#change-81653

* Author: sbellware (Scott Bellware)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
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)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>