Project

General

Profile

Actions

Bug #14658

closed

Kernel#singleton_method is incompatible with Module#prepend.

Added by nashby (Vasiliy Ermolovich) about 4 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:86435]

Description

It's not possible to get singleton method using Kernel#singleton_method if singleton class was prepended with any module:

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) fix_singleton-method-prepend.patch nashby (Vasiliy Ermolovich), 04/02/2018 03:25 PM
Actions

Also available in: Atom PDF