diff options
author | Nobuyoshi Nakada <[email protected]> | 2020-07-30 02:28:46 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <[email protected]> | 2020-07-30 02:28:46 +0900 |
commit | 28cd254b498e34b3fb205cfb116bff3f946d2fdc (patch) | |
tree | 0fee6348b7f3a6d1debdf3aaae813b9c3a2b9b24 /class.c | |
parent | 478dc67cf5043ef8aa3692ab17669606e364fe7c (diff) |
Set cloned flag after checked if copiable
Diffstat (limited to 'class.c')
-rw-r--r-- | class.c | 9 |
1 files changed, 5 insertions, 4 deletions
@@ -354,16 +354,17 @@ static void ensure_origin(VALUE klass); VALUE rb_mod_init_copy(VALUE clone, VALUE orig) { + if (RB_TYPE_P(clone, T_CLASS)) { + class_init_copy_check(clone, orig); + } + if (!OBJ_INIT_COPY(clone, orig)) return clone; + /* cloned flag is refer at constant inline cache * see vm_get_const_key_cref() in vm_insnhelper.c */ FL_SET(clone, RCLASS_CLONED); FL_SET(orig , RCLASS_CLONED); - if (RB_TYPE_P(clone, T_CLASS)) { - class_init_copy_check(clone, orig); - } - if (!OBJ_INIT_COPY(clone, orig)) return clone; if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) { RBASIC_SET_CLASS(clone, rb_singleton_class_clone(orig)); rb_singleton_class_attached(RBASIC(clone)->klass, (VALUE)clone); |