Issue #9451 has been updated by Yukihiro Matsumoto.

Assignee set to Shugo Maeda

As `#===` from case statement and `#each` from for statement, I think refinement should be effective to methods that called implicitly.  Let us discuss about the issue.

Matz.


----------------------------------------
Bug #9451: Refinements and unary & (to_proc)
https://bugs.ruby-lang.org/issues/9451#change-44668

* Author: Jan Lelis
* Status: Open
* Priority: Normal
* Assignee: Shugo Maeda
* Category: 
* Target version: 
* ruby -v: ruby 2.2.0dev (2014-01-25 trunk 44707) [x86_64-linux]
* Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------
Not sure if this is a bug or feature request:

    require 'minitest/autorun'
    require 'set'
    
    module ClassToProc
      refine Class do
        def to_proc
          lambda{ |*args| self.new(*args) }
        end
      end
    end
    
    using ClassToProc
    
    describe 'Class#to_proc' do
      it 'works when called directly' do
        Set.to_proc[[1,2]].must_equal Set[1,2]
      end
    
      it 'fails when called via ampersand' do
        [[1,2]].map(&Set).must_equal [Set[1,2]]
      end
    end

The second example errors with *NoMethodError: super: no superclass method `to_proc' for Set:Class*

Would be great to have it, though.



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