summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-09 14:54:27 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-05-09 14:54:27 +0000
commit2c240c5e49e618f769d8c8082ab9c4d088f68411 (patch)
tree440ca32c67b210c68ea9dd70bf3130a4f92e1855
parent4c1f8acd2ac14ffce1e1d9f414c700f293a7bdc6 (diff)
merge revision(s) 40612,40614: [Backport #8025]
* class.c (rb_mod_included_modules): should not include the original module itself. [ruby-core:53158] [Bug #8025] * 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/branches/ruby_2_0_0@40627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog10
-rw-r--r--class.c7
-rw-r--r--test/ruby/test_module.rb15
-rw-r--r--version.h6
4 files changed, 33 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index d629418aba..de33ca6c2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Thu May 9 23:39:47 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * class.c (rb_mod_included_modules): should not include non-modules.
+ [ruby-core:53158] [Bug #8025]
+
+Thu May 9 23:39:47 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * class.c (rb_mod_included_modules): should not include the original
+ module itself. [ruby-core:53158] [Bug #8025]
+
Wed May 8 23:07:19 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* insns.def (defined): use vm_search_superclass() like as normal super
diff --git a/class.c b/class.c
index 85ce5b88bb..f9f5dd84c2 100644
--- a/class.c
+++ b/class.c
@@ -853,10 +853,13 @@ rb_mod_included_modules(VALUE mod)
{
VALUE ary = rb_ary_new();
VALUE p;
+ VALUE origin = RCLASS_ORIGIN(mod);
for (p = RCLASS_SUPER(mod); p; p = RCLASS_SUPER(p)) {
- if (BUILTIN_TYPE(p) == T_ICLASS) {
- rb_ary_push(ary, RBASIC(p)->klass);
+ if (p != origin && BUILTIN_TYPE(p) == T_ICLASS) {
+ 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 e7523f6a1e..7dd5cce90f 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1508,6 +1508,21 @@ class TestModule < Test::Unit::TestCase
assert_nothing_raised(NoMethodError) {a.send :foo}
end
+ def test_prepend_included_modules
+ bug8025 = '[ruby-core:53158] [Bug #8025]'
+ mixin = labeled_module("mixin")
+ c = labeled_module("c") {prepend mixin}
+ 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
m = Module.new
m.class_variable_set(:@@foo, 1)
diff --git a/version.h b/version.h
index 0612099913..499b74fc96 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2013-05-08"
-#define RUBY_PATCHLEVEL 188
+#define RUBY_RELEASE_DATE "2013-05-09"
+#define RUBY_PATCHLEVEL 189
#define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 5
-#define RUBY_RELEASE_DAY 8
+#define RUBY_RELEASE_DAY 9
#include "ruby/version.h"