Call `#initialize_copy` from `init_copy` only if it's redefined.

parent 52dd0a8c
......@@ -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,7 +312,9 @@ init_copy(mrb_state *mrb, mrb_value dest, mrb_value obj)
default:
break;
}
mrb_funcall_id(mrb, dest, MRB_SYM(initialize_copy), 1, obj);
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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment