ruby-changes:45582
From: nobu <ko1@a...>
Date: Sun, 19 Feb 2017 10:27:56 +0900 (JST)
Subject: [ruby-changes:45582] nobu:r57655 (trunk): vm_insnhelper.c: super to module in refinement
nobu 2017-02-19 10:27:52 +0900 (Sun, 19 Feb 2017) New Revision: 57655 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=57655 Log: vm_insnhelper.c: super to module in refinement * vm_insnhelper.c (vm_call_zsuper): method defined in module in refinement is not callable as-is. dispatch again. [ruby-core:79588] [Bug #13227] Modified files: trunk/test/ruby/test_refinement.rb trunk/vm_insnhelper.c Index: test/ruby/test_refinement.rb =================================================================== --- test/ruby/test_refinement.rb (revision 57654) +++ test/ruby/test_refinement.rb (revision 57655) @@ -1829,6 +1829,38 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/ruby/test_refinement.rb#L1829 end; end + module SuperToModule + class Parent + end + + class Child < Parent + end + + module FooBar + refine Parent do + def to_s + "Parent" + end + end + + refine Child do + def to_s + super + " -> Child" + end + end + end + + using FooBar + def Child.test + new.to_s + end + end + + def test_super_to_module + bug = '[ruby-core:79588] [Bug #13227]' + assert_equal("Parent -> Child", SuperToModule::Child.test, bug) + end + private def eval_using(mod, s) Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 57654) +++ vm_insnhelper.c (revision 57655) @@ -2026,7 +2026,8 @@ vm_call_zsuper(rb_thread_t *th, rb_contr https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2026 if (!cc->me) { return vm_call_method_nome(th, cfp, calling, ci, cc); } - if (cc->me->def->type == VM_METHOD_TYPE_REFINED) { + if (cc->me->def->type == VM_METHOD_TYPE_REFINED && + cc->me->def->body.refined.orig_me) { cc->me = refined_method_callable_without_refinement(cc->me); } return vm_call_method_each_type(th, cfp, calling, ci, cc); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/