Bug #14658
closed
Kernel#singleton_method is incompatible with Module#prepend.
Added by nashby (Vasiliy Ermolovich) over 6 years ago.
Updated about 6 years ago.
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
- Status changed from Open to Closed
Applied in changeset trunk|r63067.
Fix Kernel#singleton_method with Module#Prepend
- proc.c (rb_obj_singleton_method): search the method entry from
the origin class, for fix prepended modules. [Bug #14658]
From: Vasiliy Ermolovich younash@gmail.com
- Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: REQUIRED
- 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.
- 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.
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0