aboutsummaryrefslogtreecommitdiffstats
path: root/vm_args.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-18 13:59:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-12-18 13:59:46 +0000
commit188b67397315283a86388531f87bac4384a5af00 (patch)
tree4ac8ab419dae7e469eae3544b43ab8c2f707b48b /vm_args.c
parent1df9c2bc1cde43d454146691ea9a68f2ff6fbe16 (diff)
downloadruby-188b67397315283a86388531f87bac4384a5af00.tar.gz
Enable refinements on symbol-proc in ruby-level methods
* vm_args.c (refine_sym_proc_call): resolve refinements when the proc is invoked, instead of resolving at making the proc, to enable refinements on symbol-proc in ruby-level methods * vm.c (vm_cref_dup): clear cached symbol-procs when duplicating. [Bug #15114] [Fix GH-2039] From: manga_osyo <manga.osyo@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_args.c')
-rw-r--r--vm_args.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/vm_args.c b/vm_args.c
index 16284c0f33..af192da979 100644
--- a/vm_args.c
+++ b/vm_args.c
@@ -851,13 +851,18 @@ refine_sym_proc_call(RB_BLOCK_CALL_FUNC_ARGLIST(yielded_arg, callback_arg))
ID mid;
const rb_callable_method_entry_t *me;
rb_execution_context_t *ec;
+ const VALUE symbol = RARRAY_AREF(callback_arg, 0);
+ const VALUE refinements = RARRAY_AREF(callback_arg, 1);
if (argc-- < 1) {
rb_raise(rb_eArgError, "no receiver given");
}
obj = *argv++;
- mid = SYM2ID(callback_arg);
- me = rb_callable_method_entry_with_refinements(CLASS_OF(obj), mid, NULL);
+
+ mid = SYM2ID(symbol);
+ me = rb_callable_method_entry(CLASS_OF(obj), mid);
+ me = rb_resolve_refined_method_callable(refinements, me);
+
ec = GET_EC();
if (!NIL_P(blockarg)) {
vm_passed_block_handler_set(ec, blockarg);
@@ -888,7 +893,8 @@ vm_caller_setup_arg_block(const rb_execution_context_t *ec, rb_control_frame_t *
VALUE func = rb_hash_lookup(ref, block_code);
if (NIL_P(func)) {
/* TODO: limit cached funcs */
- func = rb_func_proc_new(refine_sym_proc_call, block_code);
+ VALUE callback_arg = rb_ary_new_from_args(2, block_code, ref);
+ func = rb_func_proc_new(refine_sym_proc_call, callback_arg);
rb_hash_aset(ref, block_code, func);
}
block_code = func;