aboutsummaryrefslogtreecommitdiffstats
path: root/class.c
diff options
context:
space:
mode:
Diffstat (limited to 'class.c')
-rw-r--r--class.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/class.c b/class.c
index 2e4b31d7c6..f17e7f053a 100644
--- a/class.c
+++ b/class.c
@@ -911,17 +911,22 @@ include_modules_at(const VALUE klass, VALUE c, VALUE module, int search_super)
}
while (module) {
+ int origin_seen = FALSE;
int superclass_seen = FALSE;
struct rb_id_table *tbl;
+ if (klass == c)
+ origin_seen = TRUE;
if (klass_m_tbl && klass_m_tbl == RCLASS_M_TBL(module))
return -1;
/* ignore if the module included already in superclasses */
for (p = RCLASS_SUPER(klass); p; p = RCLASS_SUPER(p)) {
int type = BUILTIN_TYPE(p);
+ if (c == p)
+ origin_seen = TRUE;
if (type == T_ICLASS) {
if (RCLASS_M_TBL(p) == RCLASS_M_TBL(module)) {
- if (!superclass_seen) {
+ if (!superclass_seen && origin_seen) {
c = p; /* move insertion point */
}
goto skip;