[前][次][番号順一覧][スレッド一覧]

ruby-changes:28560

From: nobu <ko1@a...>
Date: Wed, 8 May 2013 22:47:23 +0900 (JST)
Subject: [ruby-changes:28560] nobu:r40612 (trunk): class.c: exclude original module

nobu	2013-05-08 22:47:11 +0900 (Wed, 08 May 2013)

  New Revision: 40612

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40612

  Log:
    class.c: exclude original module
    
    * class.c (rb_mod_included_modules): should not include the original
      module itself.  [ruby-core:53158] [Bug #8025]

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/test/ruby/test_module.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40611)
+++ ChangeLog	(revision 40612)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed May  8 22:46:59 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* class.c (rb_mod_included_modules): should not include the original
+	  module itself.  [ruby-core:53158] [Bug #8025]
+
 Wed May  8 17:43:55 2013  NARUSE, Yui  <naruse@r...>
 
 	* io.c (rb_io_ext_int_to_encs): ignore internal encoding if external
Index: class.c
===================================================================
--- class.c	(revision 40611)
+++ class.c	(revision 40612)
@@ -851,9 +851,10 @@ rb_mod_included_modules(VALUE mod) https://github.com/ruby/ruby/blob/trunk/class.c#L851
 {
     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) {
+	if (p != origin && BUILTIN_TYPE(p) == T_ICLASS) {
 	    rb_ary_push(ary, RBASIC(p)->klass);
 	}
     }
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 40611)
+++ test/ruby/test_module.rb	(revision 40612)
@@ -1548,6 +1548,13 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1548
     assert_nothing_raised(NoMethodError, bug8005) {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}
+    assert_not_include(c.included_modules, c, bug8025)
+  end
+
   def test_class_variables
     m = Module.new
     m.class_variable_set(:@@foo, 1)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]