summaryrefslogtreecommitdiff
path: root/vm_args.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-24 06:25:02 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-24 06:25:02 +0000
commita6e5073c573ce78b46445278cbfb8432464fa96d (patch)
treebc718e6a7c9afdf72f5451e1952f1b014b5d25cd /vm_args.c
parentc786db207a1aa7f4e0667b92d8c77fda99580370 (diff)
downloadruby-a6e5073c573ce78b46445278cbfb8432464fa96d.tar.gz
vm_args.c: to_proc refinements
* vm_args.c (vm_to_proc): enable #to_proc by refinements at Proc passing as a block. patched by osyo (manga osyo). [Feature #14223] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62020 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_args.c')
-rw-r--r--vm_args.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/vm_args.c b/vm_args.c
index 7a2f8135da..3bb2bd0a4b 100644
--- a/vm_args.c
+++ b/vm_args.c
@@ -792,7 +792,16 @@ vm_to_proc(VALUE proc)
{
if (UNLIKELY(!rb_obj_is_proc(proc))) {
VALUE b;
- b = rb_check_convert_type_with_id(proc, T_DATA, "Proc", idTo_proc);
+ const rb_callable_method_entry_t *me =
+ rb_callable_method_entry_with_refinements(CLASS_OF(proc), idTo_proc, NULL);
+
+ if (me) {
+ b = vm_call0(GET_EC(), proc, idTo_proc, 0, NULL, me);
+ }
+ else {
+ /* NOTE: calling method_missing */
+ b = rb_check_convert_type_with_id(proc, T_DATA, "Proc", idTo_proc);
+ }
if (NIL_P(b) || !rb_obj_is_proc(b)) {
rb_raise(rb_eTypeError,