From 2103333e783b525f5d31195aa771d4bc91443e82 Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 18 Dec 2018 08:33:20 +0000 Subject: should use defined_class. * vm_insnhelper.c (vm_call_method_each_type): we should use me->defined_class instead of me->owner because me->owner doesn't has correct ancestors list. [Bug #15427] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_module.rb | 18 ++++++++++++++++++ vm_insnhelper.c | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb index 15a39346dd..4ca0e09277 100644 --- a/test/ruby/test_module.rb +++ b/test/ruby/test_module.rb @@ -2352,6 +2352,24 @@ class TestModule < Test::Unit::TestCase end; end + def test_private_extended_module + assert_separately [], %q{ + class Object + def bar; "Object#bar"; end + end + module M1 + def bar; super; end + end + module M2 + include M1 + private(:bar) + def foo; bar; end + end + extend M2 + assert_equal 'Object#bar', foo + } + end + private def assert_top_method_is_private(method) diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 7080434543..1cdc50b2b9 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2292,7 +2292,7 @@ vm_call_method_each_type(rb_execution_context_t *ec, rb_control_frame_t *cfp, st break; case VM_METHOD_TYPE_ZSUPER: - return vm_call_zsuper(ec, cfp, calling, ci, cc, RCLASS_ORIGIN(cc->me->owner)); + return vm_call_zsuper(ec, cfp, calling, ci, cc, RCLASS_ORIGIN(cc->me->defined_class)); case VM_METHOD_TYPE_REFINED: { const rb_cref_t *cref = rb_vm_get_cref(cfp->ep); -- cgit v1.2.3