mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
042be439d9
commit
11a9f7ab94
Notes:
git
2019-08-31 04:40:14 +09:00
2 changed files with 54 additions and 28 deletions
|
@ -2295,6 +2295,34 @@ class TestRefinement < Test::Unit::TestCase
|
||||||
d
|
d
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class RefineInUsing
|
||||||
|
module M1
|
||||||
|
refine RefineInUsing do
|
||||||
|
def foo
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
module M2
|
||||||
|
using M1
|
||||||
|
refine RefineInUsing do
|
||||||
|
def call_foo
|
||||||
|
RefineInUsing.new.foo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
using M2
|
||||||
|
def self.test
|
||||||
|
new.call_foo
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_refine_in_using
|
||||||
|
assert_equal(:ok, RefineInUsing.test)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def eval_using(mod, s)
|
def eval_using(mod, s)
|
||||||
|
|
|
@ -2604,15 +2604,13 @@ vm_call_method_each_type(rb_execution_context_t *ec, rb_control_frame_t *cfp, st
|
||||||
|
|
||||||
case VM_METHOD_TYPE_REFINED: {
|
case VM_METHOD_TYPE_REFINED: {
|
||||||
const rb_cref_t *cref = vm_get_cref(cfp->ep);
|
const rb_cref_t *cref = vm_get_cref(cfp->ep);
|
||||||
VALUE refinements = cref ? CREF_REFINEMENTS(cref) : Qnil;
|
|
||||||
VALUE refinement;
|
for (; cref; cref = CREF_NEXT(cref)) {
|
||||||
const rb_callable_method_entry_t *ref_me;
|
const rb_callable_method_entry_t *ref_me;
|
||||||
|
VALUE refinements = CREF_REFINEMENTS(cref);
|
||||||
|
VALUE refinement = find_refinement(refinements, cc->me->owner);
|
||||||
|
if (NIL_P(refinement)) continue;
|
||||||
|
|
||||||
refinement = find_refinement(refinements, cc->me->owner);
|
|
||||||
|
|
||||||
if (NIL_P(refinement)) {
|
|
||||||
goto no_refinement_dispatch;
|
|
||||||
}
|
|
||||||
ref_me = rb_callable_method_entry(refinement, ci->mid);
|
ref_me = rb_callable_method_entry(refinement, ci->mid);
|
||||||
|
|
||||||
if (ref_me) {
|
if (ref_me) {
|
||||||
|
@ -2620,7 +2618,7 @@ vm_call_method_each_type(rb_execution_context_t *ec, rb_control_frame_t *cfp, st
|
||||||
const rb_control_frame_t *top_cfp = current_method_entry(ec, cfp);
|
const rb_control_frame_t *top_cfp = current_method_entry(ec, cfp);
|
||||||
const rb_callable_method_entry_t *top_me = rb_vm_frame_method_entry(top_cfp);
|
const rb_callable_method_entry_t *top_me = rb_vm_frame_method_entry(top_cfp);
|
||||||
if (top_me && rb_method_definition_eq(ref_me->def, top_me->def)) {
|
if (top_me && rb_method_definition_eq(ref_me->def, top_me->def)) {
|
||||||
goto no_refinement_dispatch;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cc->me->def->type != VM_METHOD_TYPE_REFINED ||
|
if (cc->me->def->type != VM_METHOD_TYPE_REFINED ||
|
||||||
|
@ -2635,8 +2633,8 @@ vm_call_method_each_type(rb_execution_context_t *ec, rb_control_frame_t *cfp, st
|
||||||
cc->me = NULL;
|
cc->me = NULL;
|
||||||
return vm_call_method_nome(ec, cfp, calling, ci, cc);
|
return vm_call_method_nome(ec, cfp, calling, ci, cc);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
no_refinement_dispatch:
|
|
||||||
if (cc->me->def->body.refined.orig_me) {
|
if (cc->me->def->body.refined.orig_me) {
|
||||||
cc->me = refined_method_callable_without_refinement(cc->me);
|
cc->me = refined_method_callable_without_refinement(cc->me);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue