summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authorShugo Maeda <shugo@ruby-lang.org>2021-08-20 10:42:01 +0900
committerShugo Maeda <shugo@ruby-lang.org>2021-08-20 10:42:01 +0900
commit754adbee91c2d4a4e84e9271724ca33f630d1916 (patch)
treed9966836716bf62947f861a388186f0158bcaebe /class.c
parent70510d1545da64604de148898e16459fad2041fe (diff)
Module#ancestors should not return superclasses of refinements
[ruby-core:86949] [Bug #14744] Reported by Eregon (Benoit Daloze). Thanks!
Diffstat (limited to 'class.c')
-rw-r--r--class.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/class.c b/class.c
index 41dbcf5150..9e5cf5416f 100644
--- a/class.c
+++ b/class.c
@@ -1347,8 +1347,13 @@ VALUE
rb_mod_ancestors(VALUE mod)
{
VALUE p, ary = rb_ary_new();
+ VALUE refined_class = Qnil;
+ if (FL_TEST(mod, RMODULE_IS_REFINEMENT)) {
+ refined_class = rb_refinement_module_get_refined_class(mod);
+ }
for (p = mod; p; p = RCLASS_SUPER(p)) {
+ if (p == refined_class) break;
if (p != RCLASS_ORIGIN(p)) continue;
if (BUILTIN_TYPE(p) == T_ICLASS) {
rb_ary_push(ary, RBASIC(p)->klass);