Issue #14658 has been updated by nagachika (Tomoyuki Chikanaga).

Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: REQUIRED to 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: DONE

ruby_2_5 r64981 merged revision(s) 63067,63068.

----------------------------------------
Bug #14658: Kernel#singleton_method is incompatible with Module#prepend.
https://bugs.ruby-lang.org/issues/14658#change-74365

* Author: nashby (Vasiliy Ermolovich)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.5.0
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: DONE
----------------------------------------
It's not possible to get singleton method using Kernel#singleton_method if singleton class was prepended with any module:

~~~ ruby
module Empty; end

class MyClass
  singleton_class.prepend(Empty)

  def self.foo; end
end

MyClass.singleton_methods(false) # => [:foo]
MyClass.singleton_method(:foo) # => NameError (undefined singleton method `foo' for `MyClass')
~~~

Attached patch fixes it. 


---Files--------------------------------
fix_singleton-method-prepend.patch (1.88 KB)


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