Merge pull request #3604 from keizo042/fix_issue3598

Find Class/Module in nested singleton class; fix #3598
This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-04-13 00:42:27 +09:00
committed by GitHub
+4 -4
View File
@@ -953,14 +953,14 @@ mrb_vm_const_get(mrb_state *mrb, mrb_sym sym)
if (c->iv && iv_get(mrb, c->iv, sym, &v)) {
return v;
}
if (c->tt == MRB_TT_SCLASS) {
c2 = c;
while (c2 && c2->tt == MRB_TT_SCLASS) {
mrb_value klass;
klass = mrb_obj_iv_get(mrb, (struct RObject *)c,
klass = mrb_obj_iv_get(mrb, (struct RObject *)c2,
mrb_intern_lit(mrb, "__attached__"));
c2 = mrb_class_ptr(klass);
if (c2->tt == MRB_TT_CLASS || c2->tt == MRB_TT_MODULE)
c = c2;
}
if (c2->tt == MRB_TT_CLASS || c2->tt == MRB_TT_MODULE) c = c2;
c2 = c;
for (;;) {
c2 = mrb_class_outer_module(mrb, c2);