Project

General

Profile

Actions

Feature #12079

closed

Loosening the condition for refinement

Added by sawa (Tsuyoshi Sawada) about 8 years ago. Updated over 7 years ago.

Status:
Rejected
Target version:
-
[ruby-core:73845]

Description

There are a few non-standard ways of calling a method that cannot be used when the relevant method is a refined method:

  • a symbol used with & as a block via symbol to proc
  • a symbol used with send or __send__

For example, the following will fail:

    module Foo
      refine String
        def baz; end
      end
    end

    using Foo
    ["a", "b", "c"].map(&:baz) # => undefined method error
    "a".send(:baz) # => undefined method error

I would like to propose to loosen the condition for refinement so that as long as the relevant construction (such as the use of & to provoke Symbol#to_proc or calling of send or __send__) is within the valid scope of refinement, allow the call to the relevant methods.


Related issues 3 (0 open3 closed)

Has duplicate Ruby master - Bug #12530: Module RefinementsRejectedshugo (Shugo Maeda)Actions
Is duplicate of Ruby master - Feature #9451: Refinements and unary & (to_proc)Closedmatz (Yukihiro Matsumoto)Actions
Is duplicate of Ruby master - Feature #11476: Methods defined in Refinements cannot be called via sendClosedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0