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

ruby-changes:28509

From: nobu <ko1@a...>
Date: Thu, 2 May 2013 23:24:09 +0900 (JST)
Subject: [ruby-changes:28509] nobu:r40561 (trunk): object.c: skip prepending modules

nobu	2013-05-02 23:23:56 +0900 (Thu, 02 May 2013)

  New Revision: 40561

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

  Log:
    object.c: skip prepending modules
    
    * object.c (rb_obj_is_kind_of): skip prepending modules.
      [ruby-core:54742] [Bug #8357]
    * object.c (rb_class_inherited_p): ditto.
      [ruby-core:54736] [Bug #8357]

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

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40560)
+++ ChangeLog	(revision 40561)
@@ -1,3 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu May  2 23:23:49 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* object.c (rb_obj_is_kind_of): skip prepending modules.
+	  [ruby-core:54742] [Bug #8357]
+
+	* object.c (rb_class_inherited_p): ditto.
+	  [ruby-core:54736] [Bug #8357]
+
 Thu May  2 22:11:47 2013  Nobuyoshi Nakada  <nobu@r...>
 
 	* bin/irb: remove dead code from sample/irb.rb.
Index: object.c
===================================================================
--- object.c	(revision 40560)
+++ object.c	(revision 40561)
@@ -599,6 +599,7 @@ rb_obj_is_kind_of(VALUE obj, VALUE c) https://github.com/ruby/ruby/blob/trunk/object.c#L599
     VALUE cl = CLASS_OF(obj);
 
     c = class_or_module_required(c);
+    c = RCLASS_ORIGIN(c);
     while (cl) {
 	if (cl == c || RCLASS_M_TBL(cl) == RCLASS_M_TBL(c))
 	    return Qtrue;
@@ -1511,6 +1512,7 @@ rb_class_inherited_p(VALUE mod, VALUE ar https://github.com/ruby/ruby/blob/trunk/object.c#L1512
     if (!CLASS_OR_MODULE_P(arg)) {
 	rb_raise(rb_eTypeError, "compared with non class/module");
     }
+    arg = RCLASS_ORIGIN(arg);
     while (mod) {
 	if (RCLASS_M_TBL(mod) == RCLASS_M_TBL(arg))
 	    return Qtrue;
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 40560)
+++ test/ruby/test_module.rb	(revision 40561)
@@ -1408,6 +1408,13 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1408
     c = labeled_class("c") {prepend b}
     assert_operator(c, :<, b, bug6654)
     assert_operator(c, :<, a, bug6654)
+    bug8357 = '[ruby-core:54736] [Bug #8357]'
+    b = labeled_module("b") {prepend a}
+    c = labeled_class("c") {include b}
+    assert_operator(c, :<, b, bug8357)
+    assert_operator(c, :<, a, bug8357)
+    bug8357 = '[ruby-core:54742] [Bug #8357]'
+    assert_kind_of(b, c.new, bug8357)
   end
 
   def test_prepend_instance_methods
@@ -1487,14 +1494,14 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1494
 
   def labeled_module(name, &block)
     Module.new do
-      singleton_class.class_eval {define_method(:to_s) {name}}
+      singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
       class_eval(&block) if block
     end
   end
 
   def labeled_class(name, superclass = Object, &block)
     Class.new(superclass) do
-      singleton_class.class_eval {define_method(:to_s) {name}}
+      singleton_class.class_eval {define_method(:to_s) {name}; alias inspect to_s}
       class_eval(&block) if block
     end
   end

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

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