mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
merge revision(s) 59444,59445: [Backport #13776]
adjust indent [ci skip] * vm_insnhelper.c (vm_call_method_each_type): adjust indent of a block in switch. visibility of inherited method * vm_insnhelper.c (vm_call_method_each_type): honor the original visibility of inherited methods when a refinement is defined but not activated. [ruby-core:82209] [Bug #13776] Author: Mon_Ouie (Mon ouie) <mon.ouie@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@62134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ecb7182f93
commit
1aee5acdae
4 changed files with 97 additions and 38 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
Wed Jan 31 22:12:48 2018 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
adjust indent
|
||||
|
||||
* vm_insnhelper.c (vm_call_method_each_type): adjust indent of a
|
||||
block in switch.
|
||||
|
||||
visibility of inherited method
|
||||
|
||||
* vm_insnhelper.c (vm_call_method_each_type): honor the original
|
||||
visibility of inherited methods when a refinement is defined but
|
||||
not activated. [ruby-core:82209] [Bug #13776]
|
||||
|
||||
Author: Mon_Ouie (Mon ouie) <mon.ouie@gmail.com>
|
||||
|
||||
Wed Jan 31 20:47:07 2018 NARUSE, Yui <naruse@ruby-lang.org>
|
||||
|
||||
HTTPHeader#add_field should allow binary [Bug #13926]
|
||||
|
|
|
@ -1673,6 +1673,49 @@ class TestRefinement < Test::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
class ParentDefiningPrivateMethod
|
||||
private
|
||||
def some_inherited_method
|
||||
end
|
||||
end
|
||||
|
||||
module MixinDefiningPrivateMethod
|
||||
private
|
||||
def some_included_method
|
||||
end
|
||||
end
|
||||
|
||||
class SomeChildClassToRefine < ParentDefiningPrivateMethod
|
||||
include MixinDefiningPrivateMethod
|
||||
private
|
||||
def some_method
|
||||
end
|
||||
end
|
||||
|
||||
def test_refine_inherited_method_with_visibility_changes
|
||||
Module.new do
|
||||
refine(SomeChildClassToRefine) do
|
||||
def some_inherited_method; end
|
||||
def some_included_method; end
|
||||
def some_method; end
|
||||
end
|
||||
end
|
||||
|
||||
obj = SomeChildClassToRefine.new
|
||||
|
||||
assert_raise_with_message(NoMethodError, /private/) do
|
||||
obj.some_inherited_method
|
||||
end
|
||||
|
||||
assert_raise_with_message(NoMethodError, /private/) do
|
||||
obj.some_included_method
|
||||
end
|
||||
|
||||
assert_raise_with_message(NoMethodError, /private/) do
|
||||
obj.some_method
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def eval_using(mod, s)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#define RUBY_VERSION "2.3.7"
|
||||
#define RUBY_RELEASE_DATE "2018-01-31"
|
||||
#define RUBY_PATCHLEVEL 395
|
||||
#define RUBY_PATCHLEVEL 396
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2018
|
||||
#define RUBY_RELEASE_MONTH 1
|
||||
|
|
|
@ -2073,48 +2073,49 @@ vm_call_method_each_type(rb_thread_t *th, rb_control_frame_t *cfp, struct rb_cal
|
|||
return vm_call_zsuper(th, cfp, calling, ci, cc, RCLASS_ORIGIN(cc->me->owner));
|
||||
|
||||
case VM_METHOD_TYPE_REFINED: {
|
||||
const rb_cref_t *cref = rb_vm_get_cref(cfp->ep);
|
||||
VALUE refinements = cref ? CREF_REFINEMENTS(cref) : Qnil;
|
||||
VALUE refinement;
|
||||
const rb_callable_method_entry_t *ref_me;
|
||||
const rb_cref_t *cref = rb_vm_get_cref(cfp->ep);
|
||||
VALUE refinements = cref ? CREF_REFINEMENTS(cref) : Qnil;
|
||||
VALUE refinement;
|
||||
const rb_callable_method_entry_t *ref_me;
|
||||
|
||||
refinement = find_refinement(refinements, cc->me->owner);
|
||||
refinement = find_refinement(refinements, cc->me->owner);
|
||||
|
||||
if (NIL_P(refinement)) {
|
||||
goto no_refinement_dispatch;
|
||||
}
|
||||
ref_me = rb_callable_method_entry(refinement, ci->mid);
|
||||
if (NIL_P(refinement)) {
|
||||
goto no_refinement_dispatch;
|
||||
}
|
||||
ref_me = rb_callable_method_entry(refinement, ci->mid);
|
||||
|
||||
if (ref_me) {
|
||||
if (cc->call == vm_call_super_method) {
|
||||
const rb_control_frame_t *top_cfp = current_method_entry(th, 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)) {
|
||||
goto no_refinement_dispatch;
|
||||
}
|
||||
}
|
||||
cc->me = ref_me;
|
||||
if (ref_me->def->type != VM_METHOD_TYPE_REFINED) {
|
||||
return vm_call_method(th, cfp, calling, ci, cc);
|
||||
}
|
||||
}
|
||||
else {
|
||||
cc->me = NULL;
|
||||
return vm_call_method_nome(th, cfp, calling, ci, cc);
|
||||
}
|
||||
if (ref_me) {
|
||||
if (cc->call == vm_call_super_method) {
|
||||
const rb_control_frame_t *top_cfp = current_method_entry(th, 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)) {
|
||||
goto no_refinement_dispatch;
|
||||
}
|
||||
}
|
||||
cc->me = ref_me;
|
||||
if (ref_me->def->type != VM_METHOD_TYPE_REFINED) {
|
||||
return vm_call_method(th, cfp, calling, ci, cc);
|
||||
}
|
||||
}
|
||||
else {
|
||||
cc->me = NULL;
|
||||
return vm_call_method_nome(th, cfp, calling, ci, cc);
|
||||
}
|
||||
|
||||
no_refinement_dispatch:
|
||||
if (cc->me->def->body.refined.orig_me) {
|
||||
cc->me = refined_method_callable_without_refinement(cc->me);
|
||||
no_refinement_dispatch:
|
||||
if (cc->me->def->body.refined.orig_me) {
|
||||
cc->me = refined_method_callable_without_refinement(cc->me);
|
||||
|
||||
if (UNDEFINED_METHOD_ENTRY_P(cc->me)) {
|
||||
cc->me = NULL;
|
||||
}
|
||||
return vm_call_method(th, cfp, calling, ci, cc);
|
||||
}
|
||||
else {
|
||||
return vm_call_zsuper(th, cfp, calling, ci, cc, cc->me->owner);
|
||||
}
|
||||
if (UNDEFINED_METHOD_ENTRY_P(cc->me)) {
|
||||
cc->me = NULL;
|
||||
}
|
||||
}
|
||||
else {
|
||||
VALUE klass = RCLASS_SUPER(cc->me->owner);
|
||||
cc->me = klass ? rb_callable_method_entry(klass, ci->mid) : NULL;
|
||||
}
|
||||
return vm_call_method(th, cfp, calling, ci, cc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue