[ruby-core:89443] [Ruby trunk Bug#14658] Kernel#singleton_method is incompatible with Module#prepend.

From: usa@...
Date: 2018-10-17 09:25:16 UTC
List: ruby-core #89443
Issue #14658 has been updated by usa (Usaku NAKAMURA).

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

ruby_2_4 r65118 merged revision(s) 63067,63068.

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

* Author: nashby (Vasiliy Ermolovich)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 2.5.0
* Backport: 2.3: UNKNOWN, 2.4: DONE, 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:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next