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

ruby-changes:44416

From: nobu <ko1@a...>
Date: Tue, 25 Oct 2016 12:54:13 +0900 (JST)
Subject: [ruby-changes:44416] nobu:r56489 (trunk): proc.c: follow the original class

nobu	2016-10-25 12:54:09 +0900 (Tue, 25 Oct 2016)

  New Revision: 56489

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56489

  Log:
    proc.c: follow the original class
    
    * proc.c (mnew_internal): follow the original class, not to loop
      the prepended module.  [ruby-core:77591] [Bug #12832]

  Modified files:
    trunk/ChangeLog
    trunk/proc.c
    trunk/test/ruby/test_method.rb
Index: test/ruby/test_method.rb
===================================================================
--- test/ruby/test_method.rb	(revision 56488)
+++ test/ruby/test_method.rb	(revision 56489)
@@ -885,6 +885,22 @@ class TestMethod < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_method.rb#L885
     assert_nil(m, Feature9781)
   end
 
+  def test_prepended_public_zsuper
+    mod = EnvUtil.labeled_module("Mod") {private def foo; :ok end}
+    mods = [mod]
+    obj = Object.new.extend(mod)
+    class << obj
+      public :foo
+    end
+    2.times do |i|
+      mods.unshift(mod = EnvUtil.labeled_module("Mod#{i}") {def foo; end})
+      obj.singleton_class.prepend(mod)
+    end
+    m = obj.method(:foo)
+    assert_equal(mods, mods.map {m.owner.tap {m = m.super_method}})
+    assert_nil(m)
+  end
+
   def rest_parameter(*rest)
     rest
   end
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 56488)
+++ ChangeLog	(revision 56489)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Oct 25 12:54:07 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* proc.c (mnew_internal): follow the original class, not to loop
+	  the prepended module.  [ruby-core:77591] [Bug #12832]
+
 Mon Oct 24 10:52:17 2016  Nobuyoshi Nakada  <nobu@r...>
 
 	* test/lib/test/unit.rb (Test::Unit::Parallel#deal): update the
Index: proc.c
===================================================================
--- proc.c	(revision 56488)
+++ proc.c	(revision 56489)
@@ -1370,7 +1370,7 @@ mnew_internal(const rb_method_entry_t *m https://github.com/ruby/ruby/blob/trunk/proc.c#L1370
     }
     if (me->def->type == VM_METHOD_TYPE_ZSUPER) {
 	if (me->defined_class) {
-	    VALUE klass = RCLASS_SUPER(me->defined_class);
+	    VALUE klass = RCLASS_SUPER(RCLASS_ORIGIN(me->defined_class));
 	    id = me->def->original_id;
 	    me = (rb_method_entry_t *)rb_callable_method_entry_without_refinements(klass, id);
 	}

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

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