1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2017-02-19 01:27:52 +00:00
parent 7e5140e285
commit 4d47e8d993
2 changed files with 34 additions and 1 deletions

View file

@ -1829,6 +1829,38 @@ class TestRefinement < Test::Unit::TestCase
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)

View file

@ -2026,7 +2026,8 @@ vm_call_zsuper(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_calling_info
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);