summaryrefslogtreecommitdiffhomepage
path: root/src/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/class.c')
-rw-r--r--src/class.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/class.c b/src/class.c
index e3888001b..44121bce6 100644
--- a/src/class.c
+++ b/src/class.c
@@ -1531,11 +1531,18 @@ mrb_instance_new(mrb_state *mrb, mrb_value cv)
mrb_value *argv;
mrb_int argc;
mrb_sym init;
+ struct RProc *p;
mrb_get_args(mrb, "*&", &argv, &argc, &blk);
obj = mrb_instance_alloc(mrb, cv);
init = mrb_intern_lit(mrb, "initialize");
- if (!mrb_func_basic_p(mrb, obj, init, mrb_bob_init)) {
+ p = mrb_method_search(mrb, mrb_class(mrb, obj), init);
+ if (MRB_PROC_CFUNC_P(p)) {
+ if (p->body.func != mrb_bob_init) {
+ p->body.func(mrb, obj);
+ }
+ }
+ else {
mrb_funcall_with_block(mrb, obj, init, argc, argv, blk);
}