Project

General

Profile

Actions

Bug #14658

closed

Kernel#singleton_method is incompatible with Module#prepend.

Added by nashby (Vasiliy Ermolovich) almost 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 #2

Updated by nobu (Nobuyoshi Nakada) almost 4 years ago

  • 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

Actions #3

Updated by nagachika (Tomoyuki Chikanaga) almost 4 years ago

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

Updated by nagachika (Tomoyuki Chikanaga) over 3 years ago

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

Updated by usa (Usaku NAKAMURA) over 3 years ago

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

Actions

Also available in: Atom PDF