From: shevegen@... Date: 2019-08-15T23:10:32+00:00 Subject: [ruby-core:94375] [Ruby master Bug#16106] UnboundMethod owner points to base class Issue #16106 has been updated by shevegen (Robert A. Heiler). I guess the documentation could mention that behaviour so that other rubyists won't be confused, as alanwu pointed out e. g: https://ruby-doc.org/core/UnboundMethod.html#method-i-owner (Or the other documentation site; I just happen to find the above more readily via a quick google search.) On a side note, perhaps the name is not ideal, since I can see why sbellware may be surprised - UnboundMethod implies to me a method not attached to anywhere, so I was a bit surprised to see that it still has a pointer to the original class from where it was created from. Although I understand that this may be useful; it just seems a bit peculiar to me ... perhaps it is a MostlyUnboundMethod. :P ---------------------------------------- Bug #16106: UnboundMethod owner points to base class https://bugs.ruby-lang.org/issues/16106#change-80790 * Author: sbellware (Scott Bellware) * Status: Open * 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: