ruby-changes:48814
From: shugo <ko1@a...>
Date: Wed, 29 Nov 2017 17:39:52 +0900 (JST)
Subject: [ruby-changes:48814] shugo:r60931 (trunk): Unused module refinement shouldn't break method search.
shugo 2017-11-29 17:39:47 +0900 (Wed, 29 Nov 2017) New Revision: 60931 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60931 Log: Unused module refinement shouldn't break method search. Use rb_callable_method_entry_t::defined_class instead of rb_callable_method_entry_t::owner, because the superclass of iclass should be searched for modules. [ruby-core:83613] [Bug #14068] Modified files: trunk/test/ruby/test_refinement.rb trunk/vm_insnhelper.c Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 60930) +++ vm_insnhelper.c (revision 60931) @@ -2314,7 +2314,7 @@ vm_call_method_each_type(rb_execution_co https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2314 cc->me = refined_method_callable_without_refinement(cc->me); } else { - VALUE klass = RCLASS_SUPER(cc->me->owner); + VALUE klass = RCLASS_SUPER(cc->me->defined_class); cc->me = klass ? rb_callable_method_entry(klass, ci->mid) : NULL; } return vm_call_method(ec, cfp, calling, ci, cc); Index: test/ruby/test_refinement.rb =================================================================== --- test/ruby/test_refinement.rb (revision 60930) +++ test/ruby/test_refinement.rb (revision 60931) @@ -2010,6 +2010,32 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L2010 assert_equal(:foo, ToSymbol.new("foo").symbol) end + def test_unused_refinement_for_module + bug14068 = '[ruby-core:83613] [Bug #14068]' + assert_in_out_err([], <<-INPUT, ["M1#foo"], [], bug14068) + module M1 + def foo + puts "M1#foo" + end + end + + module M2 + end + + module UnusedRefinement + refine(M2) do + def foo + puts "M2#foo" + end + end + end + + include M1 + include M2 + foo() + INPUT + end + private def eval_using(mod, s) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/