summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorShugo Maeda <shugo@ruby-lang.org>2021-10-21 16:21:08 +0900
committerShugo Maeda <shugo@ruby-lang.org>2021-10-21 16:31:54 +0900
commit6606597109bdb535a150606323ce3d8f5750e1f6 (patch)
tree153eac378825ad9b17be9e8ae10d80572641f2c5 /vm.c
parent7185c00fcc330db8951b684f548ba3d10983bb92 (diff)
Deprecate include/prepend in refinements and add Refinement#import_methods instead
Refinement#import_methods imports methods from modules. Unlike Module#include, it copies methods and adds them into the refinement, so the refinement is activated in the imported methods. [Bug #17429] [ruby-core:101639]
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/vm.c b/vm.c
index 1f60906d1a..ec2f3176e6 100644
--- a/vm.c
+++ b/vm.c
@@ -294,6 +294,25 @@ vm_cref_dup(const rb_cref_t *cref)
return new_cref;
}
+
+rb_cref_t *
+rb_vm_cref_dup_without_refinements(const rb_cref_t *cref)
+{
+ VALUE klass = CREF_CLASS(cref);
+ const rb_scope_visibility_t *visi = CREF_SCOPE_VISI(cref);
+ rb_cref_t *next_cref = CREF_NEXT(cref), *new_cref;
+ int pushed_by_eval = CREF_PUSHED_BY_EVAL(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, Qnil);
+ CREF_OMOD_SHARED_UNSET(new_cref);
+ }
+
+ return new_cref;
+}
+
static rb_cref_t *
vm_cref_new_toplevel(rb_execution_context_t *ec)
{