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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0