Navigation Menu

Skip to content

Commit

Permalink
Fixed Module#include ancestor handling. Closes rubinius#692.
Browse files Browse the repository at this point in the history
* #include should add all ancestor modules that are not yet included
  when a previously included module is included again.

Signed-off-by: Eero Saynatkari <esaynatkari@engineyard.com>
  • Loading branch information
keita authored and Eero Saynatkari committed Sep 10, 2008
1 parent e568528 commit b0f00be
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions kernel/core/module.rb
Expand Up @@ -458,10 +458,22 @@ def include_cv(*modules)
raise TypeError, "wrong argument type #{mod.class} (expected Module)"
end

next if ancestors.include? mod
if mod == self
raise ArgumentError, "cyclic include detected"
end

mod.send(:append_features, self)
mod.send(:included, self)
if ancestors.include? mod
ancestor = superclass_chain.find do |m|
m.module == mod if m.kind_of?(IncludedModule)
end
ancestor.module.included_modules.each do |included_mod|
included_mod.send(:append_features, ancestor)
included_mod.send(:included, ancestor)
end
else
mod.send(:append_features, self)
mod.send(:included, self)
end
end
end

Expand Down

0 comments on commit b0f00be

Please sign in to comment.