diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-18 13:59:46 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-12-18 13:59:46 +0000 |
commit | 188b67397315283a86388531f87bac4384a5af00 (patch) | |
tree | 4ac8ab419dae7e469eae3544b43ab8c2f707b48b /vm.c | |
parent | 1df9c2bc1cde43d454146691ea9a68f2ff6fbe16 (diff) |
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.c')
-rw-r--r-- | vm.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -229,6 +229,12 @@ vm_cref_new_use_prev(VALUE klass, rb_method_visibility_t visi, int module_func, return vm_cref_new0(klass, visi, module_func, prev_cref, pushed_by_eval, TRUE); } +static int +ref_delete_symkey(VALUE key, VALUE value, VALUE unused) +{ + return SYMBOL_P(key) ? ST_DELETE : ST_CONTINUE; +} + static rb_cref_t * vm_cref_dup(const rb_cref_t *cref) { @@ -240,7 +246,9 @@ vm_cref_dup(const rb_cref_t *cref) new_cref = vm_cref_new(klass, visi->method_visi, visi->module_func, next_cref, pushed_by_eval); if (!NIL_P(CREF_REFINEMENTS(cref))) { - CREF_REFINEMENTS_SET(new_cref, rb_hash_dup(CREF_REFINEMENTS(cref))); + VALUE ref = rb_hash_dup(CREF_REFINEMENTS(cref)); + rb_hash_foreach(ref, ref_delete_symkey, Qnil); + CREF_REFINEMENTS_SET(new_cref, ref); CREF_OMOD_SHARED_UNSET(new_cref); } |