ruby-changes:49319
From: nagachika <ko1@a...>
Date: Sun, 24 Dec 2017 11:29:25 +0900 (JST)
Subject: [ruby-changes:49319] nagachika:r61436 (ruby_2_4): merge revision(s) 59444, 59445: [Backport #13776]
nagachika 2017-12-24 11:29:19 +0900 (Sun, 24 Dec 2017) New Revision: 61436 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61436 Log: 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@g...> Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/test/ruby/test_refinement.rb branches/ruby_2_4/version.h branches/ruby_2_4/vm_insnhelper.c Index: ruby_2_4/vm_insnhelper.c =================================================================== --- ruby_2_4/vm_insnhelper.c (revision 61435) +++ ruby_2_4/vm_insnhelper.c (revision 61436) @@ -2209,44 +2209,45 @@ vm_call_method_each_type(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/ruby_2_4/vm_insnhelper.c#L2209 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; - - 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 (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); - return vm_call_method(th, cfp, calling, ci, cc); - } - else { - return vm_call_zsuper(th, cfp, calling, ci, cc, cc->me->owner); - } + 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); + + 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); + } + + no_refinement_dispatch: + if (cc->me->def->body.refined.orig_me) { + cc->me = refined_method_callable_without_refinement(cc->me); + } + 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); } } Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 61435) +++ ruby_2_4/version.h (revision 61436) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.4" -#define RUBY_RELEASE_DATE "2017-12-22" -#define RUBY_PATCHLEVEL 220 +#define RUBY_RELEASE_DATE "2017-12-24" +#define RUBY_PATCHLEVEL 221 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 12 -#define RUBY_RELEASE_DAY 22 +#define RUBY_RELEASE_DAY 24 #include "ruby/version.h" Index: ruby_2_4/test/ruby/test_refinement.rb =================================================================== --- ruby_2_4/test/ruby/test_refinement.rb (revision 61435) +++ ruby_2_4/test/ruby/test_refinement.rb (revision 61436) @@ -1917,6 +1917,50 @@ class TestRefinement < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/ruby/test_refinement.rb#L1917 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) Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 61435) +++ ruby_2_4 (revision 61436) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r59444-59445 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/