summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-27 21:12:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-27 21:12:46 +0000
commit3f3225905b17b0088e7266d981200913edd778a2 (patch)
tree626b43593e08f5a8eaf75927882f19e17cfc0076 /class.c
parentc68698622021efa6cc5e70f082dba19885a6edb3 (diff)
prepend: fix ancestors order
* class.c (rb_mod_ancestors): fix ancestors order. [ruby-core:45919][Bug #6658] [ruby-dev:45861][Bug #6659] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/class.c b/class.c
index a642ff0029..9ff56f8563 100644
--- a/class.c
+++ b/class.c
@@ -838,11 +838,22 @@ VALUE
rb_mod_ancestors(VALUE mod)
{
VALUE p, ary = rb_ary_new();
+ VALUE origin = RCLASS_ORIGIN(mod);
- for (p = mod; p; p = RCLASS_SUPER(p)) {
+ p = mod;
+ if (origin == mod) {
+ origin = 0;
+ }
+ else {
+ p = RCLASS_SUPER(p);
+ }
+ for (; p; p = RCLASS_SUPER(p)) {
if (FL_TEST(p, FL_SINGLETON))
continue;
- if (BUILTIN_TYPE(p) == T_ICLASS) {
+ if (p == origin) {
+ rb_ary_push(ary, mod);
+ }
+ else if (BUILTIN_TYPE(p) == T_ICLASS) {
rb_ary_push(ary, RBASIC(p)->klass);
}
else {