Project

General

Profile

Actions

Bug #9573

closed

descendants of a module don't gain its future ancestors, but descendants of a class, do

Added by rits (First Last) over 10 years ago. Updated over 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.1p76 (2014-02-24 revision 45161) [i686-linux]
Backport:
[ruby-core:61117]

Description

module Mod1
end

module Mod2
end

class Class1
end

class Class2 < Class1
end

p Class2.ancestors - Object.ancestors # [Class2, Class1]

Class1.include Mod1

p Class2.ancestors - Object.ancestors # [Class2, Class1, Mod1]

Mod1.include Mod2

p Mod1.ancestors - Object.ancestors # [Mod1, Mod2]

p Class2.ancestors - Object.ancestors # [Class2, Class1, Mod1]

note that descendants of a class do gain its future ancestors

so 2 issues:

  1. It would seem natural that in dynamic language, dynamically added ancestors should propagate to descendants
  2. Why is there a difference in ancestor propagation between modules and classes

Files

include-future-ancestors-9573.patch (3.49 KB) include-future-ancestors-9573.patch jeremyevans0 (Jeremy Evans), 01/07/2020 04:27 PM
prepend-future-ancestors-9573.patch (6.42 KB) prepend-future-ancestors-9573.patch jeremyevans0 (Jeremy Evans), 01/08/2020 08:04 PM

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #16973: Rails Active Support unit test fails since 41582d5866Third Party's IssueActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0