Call `#initialize_copy` from `init_copy` only if it's redefined.
@@ -283,6 +283,8 @@ copy_class(mrb_state *mrb, mrb_value dst, mrb_value src)
MRB_SET_INSTANCE_TT(dc, MRB_INSTANCE_TT(sc));
}
+static mrb_value mrb_obj_init_copy(mrb_state *mrb, mrb_value self);
+
static void
init_copy(mrb_state *mrb, mrb_value dest, mrb_value obj)
{
@@ -310,8 +312,10 @@ init_copy(mrb_state *mrb, mrb_value dest, mrb_value obj)
default:
break;
}
+ if (!mrb_func_basic_p(mrb, dest, MRB_SYM(initialize_copy), mrb_obj_init_copy)) {
mrb_funcall_id(mrb, dest, MRB_SYM(initialize_copy), 1, obj);
}
+}
/* 15.3.1.3.8 */
/*
