Project

General

Profile

Actions

Bug #14658

closed

Kernel#singleton_method is incompatible with Module#prepend.

Added by nashby (Vasiliy Ermolovich) about 6 years ago. Updated over 5 years ago.

Status:
Closed
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) about 6 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

Actions #3

Updated by nagachika (Tomoyuki Chikanaga) about 6 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 5 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 5 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

Like0
Like0Like0Like0Like0Like0