From 150f937659647baf59b96acff0e81772a8b07461 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 25 Oct 2016 03:54:09 +0000 Subject: 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56489 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ proc.c | 2 +- test/ruby/test_method.rb | 16 ++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 760da60536..eacccc1cd5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Oct 25 12:54:07 2016 Nobuyoshi Nakada + + * 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 * test/lib/test/unit.rb (Test::Unit::Parallel#deal): update the diff --git a/proc.c b/proc.c index 126932e8f0..651eaaad0d 100644 --- a/proc.c +++ b/proc.c @@ -1370,7 +1370,7 @@ mnew_internal(const rb_method_entry_t *me, VALUE klass, } 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); } diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index a87f46092d..83ad484238 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -885,6 +885,22 @@ class TestMethod < Test::Unit::TestCase 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 -- cgit v1.2.3