summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-08 16:05:50 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-08 16:05:50 +0000
commite8bdef657a5502786c1eb9fe100b29c67a9a21c2 (patch)
tree3bc58cb32cc8d7acfd8a608ac346b2e16fb6763c
parent3fd0000c0cf8fedad3b8130b11c2f93a6426d6b0 (diff)
class.c: include modules only
* class.c (rb_mod_included_modules): should not include non-modules. [ruby-core:53158] [Bug #8025] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40614 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--class.c4
-rw-r--r--test/ruby/test_module.rb10
3 files changed, 17 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index ab31b7616e..e8538e31bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu May 9 01:05:41 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * class.c (rb_mod_included_modules): should not include non-modules.
+ [ruby-core:53158] [Bug #8025]
+
Wed May 8 22:46:59 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* class.c (rb_mod_included_modules): should not include the original
diff --git a/class.c b/class.c
index 29521c44b2..672a3a28fa 100644
--- a/class.c
+++ b/class.c
@@ -855,7 +855,9 @@ rb_mod_included_modules(VALUE mod)
for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) {
if (p != origin && BUILTIN_TYPE(p) == T_ICLASS) {
- rb_ary_push(ary, RBASIC(p)->klass);
+ VALUE m = RBASIC(p)->klass;
+ if (RB_TYPE_P(m, T_MODULE))
+ rb_ary_push(ary, m);
}
}
return ary;
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 45b5056927..75a7b52ca8 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1552,7 +1552,15 @@ class TestModule < Test::Unit::TestCase
bug8025 = '[ruby-core:53158] [Bug #8025]'
mixin = labeled_module("mixin")
c = labeled_module("c") {prepend mixin}
- assert_not_include(c.included_modules, c, bug8025)
+ im = c.included_modules
+ assert_not_include(im, c, bug8025)
+ assert_include(im, mixin, bug8025)
+ c1 = labeled_class("c1") {prepend mixin}
+ c2 = labeled_class("c2", c1)
+ im = c2.included_modules
+ assert_not_include(im, c1, bug8025)
+ assert_not_include(im, c2, bug8025)
+ assert_include(im, mixin, bug8025)
end
def test_class_variables