Copy iv table with #prepend; fix #5309

In addition, stop eager allocation of `mt` table.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2021-02-01 14:33:28 +09:00
parent d0ba7b95a9
commit bd6b48fa3b
+2 -1
View File
@@ -1497,7 +1497,8 @@ mrb_prepend_module(mrb_state *mrb, struct RClass *c, struct RClass *m)
origin->super = c->super;
c->super = origin;
origin->mt = c->mt;
c->mt = mt_new(mrb);
c->mt = NULL;
origin->iv = c->iv;
mrb_field_write_barrier(mrb, (struct RBasic*)c, (struct RBasic*)origin);
c->flags |= MRB_FL_CLASS_IS_PREPENDED;
}