Issue #17428 has been updated by jeremyevans0 (Jeremy Evans).


After thinking about this more, I would prefer :

```ruby
Module.method(:prepend)
# => #<Method: Module.prepend(Module#prepend)(*)>
```

Basically, show the method based on the receiver, then, if it is different, the method based on the owner.  I think this is conceptually simpler.  The only issue it will result in the method name showing up twice even if the method has not been aliased.

Additional examples:

```ruby
class A
  def self.b; end
end
class C < A;
end
C.method(:b)
# => #<Method: C.b(A.b)(*)>

module M
  def b; end
end
C.extend M
C.method(:b)
# => #<Method: C.b(M#b)(*)>

String.new.method(:to_s)
# => #<Method: String#to_s(*)>

class S < String
end
S.new.method(:to_s)
# => #<Method: S#to_s(String#to_s)(*)>
```

----------------------------------------
Bug #17428: Method#inspect bad output for class methods
https://bugs.ruby-lang.org/issues/17428#change-89514

* Author: marcandre (Marc-Andre Lafortune)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* ruby -v: ruby 3.0.0dev (2020-12-22T17:37:59Z master 487355873a) [x86_64-darwin18]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
```
$ $ ruby -e 'p String.method(:prepend)'
# 2.7.0:
#<Method: String.prepend(*)>
# 3.0.0:
#<Method: #<Class:Object>(Module)#prepend(*)>
```

@jeremyevans found it shows the method as pertaining to one level too high (which is good for objects as we don't want to show the singleton class there, but not for classes).

Probably due to #15608



-- 
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>