Get constant of parent class even if child class is defined in signleton class; fix #3575

This commit is contained in:
Kouichi Nakanishi
2017-04-06 23:31:34 +09:00
parent e5b61d34f6
commit fd0f79ca67
2 changed files with 24 additions and 1 deletions
+10 -1
View File
@@ -127,10 +127,19 @@ MRB_API struct RClass*
mrb_class_outer_module(mrb_state *mrb, struct RClass *c)
{
mrb_value outer;
struct RClass *cls;
outer = mrb_obj_iv_get(mrb, (struct RObject*)c, mrb_intern_lit(mrb, "__outer__"));
if (mrb_nil_p(outer)) return NULL;
return mrb_class_ptr(outer);
cls = mrb_class_ptr(outer);
if (cls->tt == MRB_TT_SCLASS)
{
mrb_value klass;
klass = mrb_obj_iv_get(mrb, (struct RObject *)cls,
mrb_intern_lit(mrb, "__attached__"));
cls = mrb_class_ptr(klass);
}
return cls;
}
static void