diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-24 06:25:02 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-24 06:25:02 +0000 |
commit | a6e5073c573ce78b46445278cbfb8432464fa96d (patch) | |
tree | bc718e6a7c9afdf72f5451e1952f1b014b5d25cd /vm_args.c | |
parent | c786db207a1aa7f4e0667b92d8c77fda99580370 (diff) | |
download | ruby-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.c | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -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, |