Project

General

Profile

Actions

Bug #10744

closed

Kernel#singleton_method returns refined method

Added by hanachin (Seiei Miyagi) over 9 years ago. Updated about 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.3.0dev (2015-01-15 trunk 49258) [x86_64-darwin14]
[ruby-core:67603]

Description

Kernel#singleton_method is an indirect method access.
it should not return Method object like Kernel#method.

following code does not works as I expected in ruby-trunk, 2.2.0, 2.1.5

class C
end

module RefinementBug
  refine C.singleton_class do
    def foo
    end
  end
end

p C.singleton_method(:foo)
p C.singleton_method(:foo).call

# expected:
#   refined_singleton_method.rb:11:in `singleton_method': undefined singleton method `foo' for `C' (NameError)
#   from refined_singleton_method.rb:11:in `<main>'
#
# actual:
#   #<Method: C.foo>
#   bug.rb:35:in `call': super: no superclass method `foo' for C:Class (NoMethodError)
#   from bug.rb:35:in `<main>'

Files

Updated by nobu (Nobuyoshi Nakada) over 9 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

Applied in changeset r49259.


proc.c: singleton_method should not use refinements

  • proc.c (rb_obj_singleton_method): Kernel#singleton_method should
    not use refinements, as well as Kernel#method.
    [ruby-core:67603] [Bug #10744]
Actions #3

Updated by nagachika (Tomoyuki Chikanaga) over 9 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN to 2.0.0: UNKNOWN, 2.1: REQUIRED, 2.2: REQUIRED
Actions #4

Updated by usa (Usaku NAKAMURA) over 9 years ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: REQUIRED, 2.2: REQUIRED

Updated by naruse (Yui NARUSE) about 9 years ago

  • Backport changed from 2.0.0: DONTNEED, 2.1: REQUIRED, 2.2: REQUIRED to 2.0.0: DONTNEED, 2.1: REQUIRED, 2.2: DONE

ruby_2_2 r49646 merged revision(s) 49259.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0