summaryrefslogtreecommitdiffhomepage
path: root/src/kernel.c
diff options
context:
space:
mode:
authorCorey Powell <[email protected]>2015-07-11 11:15:18 +0200
committerBlaž Hrastnik <[email protected]>2015-07-13 14:04:42 +0200
commit005cacf18b8ce2cf854872aa8cb803819478a47d (patch)
treebbb907f4a36f62612f105b4aea111ccd4acd910d /src/kernel.c
parent97529c2a9a7b75a838234a420bbe2c6dc59c56ba (diff)
downloadmruby-005cacf18b8ce2cf854872aa8cb803819478a47d.tar.gz
mruby-005cacf18b8ce2cf854872aa8cb803819478a47d.zip
Additional patches to make this work
Diffstat (limited to 'src/kernel.c')
-rw-r--r--src/kernel.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/kernel.c b/src/kernel.c
index b5b13f874..bafab6e76 100644
--- a/src/kernel.c
+++ b/src/kernel.c
@@ -248,6 +248,11 @@ mrb_singleton_class_clone(mrb_state *mrb, mrb_value obj)
clone->c = mrb_singleton_class_clone(mrb, mrb_obj_value(klass));
}
+ if (klass->origin != klass)
+ clone->origin = klass->origin;
+ else
+ clone->origin = clone;
+
clone->super = klass->super;
if (klass->iv) {
mrb_iv_copy(mrb, mrb_obj_value(clone), mrb_obj_value(klass));
@@ -269,6 +274,13 @@ copy_class(mrb_state *mrb, mrb_value dst, mrb_value src)
{
struct RClass *dc = mrb_class_ptr(dst);
struct RClass *sc = mrb_class_ptr(src);
+ /* if the origin is not the same as the class, then the origin and
+ the current class need to be copied */
+ if (sc->origin != sc) {
+ dc->origin = mrb_class_ptr(mrb_obj_dup(mrb, mrb_obj_value(sc->origin)));
+ } else {
+ dc->origin = dc;
+ }
dc->mt = kh_copy(mt, mrb, sc->mt);
dc->super = sc->super;
}