Feature #11476
closed
Methods defined in Refinements cannot be called via send
Added by matsuda (Akira Matsuda) over 9 years ago.
Updated about 8 years ago.
Description
class C end
module M
refine C do
def a() p:hello end
def b() p:world end
end
end
using M
C.new.a
C.new.send :b
% ruby -v t.rb
ruby 2.3.0dev (2015-08-22 trunk 51660) [x86_64-darwin14]
:hello
t.rb:13:in `<main>': undefined method `b' for #<C:0x007f86c9a12af0> (NoMethodError)
- Tracker changed from Bug to Feature
- Status changed from Open to Assigned
- Assignee changed from shugo (Shugo Maeda) to matz (Yukihiro Matsumoto)
Aah, I'm sorry that I missed that part of the documentation.
But indeed I felt the behaviour weird while using the feature in a real-world library.
Accepted.
The current behavior is according to the direct interpretation of the refinement spec. But many people expect send
to be another form of a method call (including refinement). And now I agree with it.
Matz
- Has duplicate Feature #12079: Loosening the condition for refinement added
- Status changed from Assigned to Closed
Applied in changeset r56450.
vm_insnhelper.c: refinements with send
- vm_insnhelper.c (vm_call_opt_send): enable refinements with
Kernel#send
and BasicObject#__send__
. [Feature #11476]
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0