From: nobu@... Date: 2015-01-15T15:26:20+00:00 Subject: [ruby-core:67606] [ruby-trunk - Bug #10744] [Closed] Kernel#singleton_method returns refined method Issue #10744 has been updated by Nobuyoshi Nakada. 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] ---------------------------------------- Bug #10744: Kernel#singleton_method returns refined method https://bugs.ruby-lang.org/issues/10744#change-51025 * 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: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- 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 `
' # # actual: # # # bug.rb:35:in `call': super: no superclass method `foo' for C:Class (NoMethodError) # from bug.rb:35:in `
' ``` ---Files-------------------------------- 0001-proc.c-Kernel-singleton_method-should-not-use-refine.patch (1.78 KB) -- https://bugs.ruby-lang.org/