summaryrefslogtreecommitdiffhomepage
path: root/src/class.c
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2020-11-21 14:53:20 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2020-11-21 15:50:16 +0900
commita7bcbd8bdc0969fbb2ee4cf37070a68de69a4b5c (patch)
treebeb39e87e84f6a9c620500fb47a18d851968232c /src/class.c
parent33f1970df23ba5eb626ad6bc99ef4584f8ba5205 (diff)
downloadmruby-a7bcbd8bdc0969fbb2ee4cf37070a68de69a4b5c.tar.gz
mruby-a7bcbd8bdc0969fbb2ee4cf37070a68de69a4b5c.zip
Fix module order of `#include`; ruby-bug:7844
Diffstat (limited to 'src/class.c')
-rw-r--r--src/class.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/class.c b/src/class.c
index f8475c3f2..e28951499 100644
--- a/src/class.c
+++ b/src/class.c
@@ -1375,8 +1375,10 @@ include_module_at(mrb_state *mrb, struct RClass *c, struct RClass *ins_pos, stru
void *klass_mt = find_origin(c)->mt;
while (m) {
- int superclass_seen = 0;
+ int original_seen = FALSE;
+ int superclass_seen = FALSE;
+ if (c == ins_pos) original_seen = TRUE;
if (m->flags & MRB_FL_CLASS_IS_PREPENDED)
goto skip;
@@ -1385,16 +1387,17 @@ include_module_at(mrb_state *mrb, struct RClass *c, struct RClass *ins_pos, stru
p = c->super;
while (p) {
+ if (c == p) original_seen = TRUE;
if (p->tt == MRB_TT_ICLASS) {
if (p->mt == m->mt) {
- if (!superclass_seen) {
+ if (!superclass_seen && original_seen) {
ins_pos = p; /* move insert point */
}
goto skip;
}
} else if (p->tt == MRB_TT_CLASS) {
if (!search_super) break;
- superclass_seen = 1;
+ superclass_seen = TRUE;
}
p = p->super;
}