[ruby-core:68181] [Ruby trunk - Bug #10744] Kernel#singleton_method returns refined method

From: naruse@...
Date: 2015-02-19 07:13:31 UTC
List: ruby-core #68181
Issue #10744 has been updated by Yui NARUSE.

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.

----------------------------------------
Bug #10744: Kernel#singleton_method returns refined method
https://bugs.ruby-lang.org/issues/10744#change-51554

* Author: Seiei Higa
* Status: Closed
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.3.0dev (2015-01-15 trunk 49258) [x86_64-darwin14]
* Backport: 2.0.0: DONTNEED, 2.1: REQUIRED, 2.2: DONE
----------------------------------------
Kernel#singleton_method is an [indirect method access](https://bugs.ruby-lang.org/projects/ruby-trunk/wiki/RefinementsSpec).
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

``` ruby
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--------------------------------
0001-proc.c-Kernel-singleton_method-should-not-use-refine.patch (1.78 KB)


-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next