summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-31 13:13:36 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-01-31 13:13:36 +0000
commit1aee5acdae7fa88e0241ed4c21ed88f775054cba (patch)
treec611f5ad265456e01e0f2b7d470960a3ac70d357
parentecb7182f93594109970db1811057c35ca71f73b2 (diff)
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
-rw-r--r--ChangeLog15
-rw-r--r--test/ruby/test_refinement.rb43
-rw-r--r--version.h2
-rw-r--r--vm_insnhelper.c85
4 files changed, 102 insertions, 43 deletions
diff --git a/ChangeLog b/ChangeLog
index 940d3a5c2d..9649c0e6a3 100644
--- a/ChangeLog
+++ b/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]
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index ac7c224c9b..8ddecfa643 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -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)
diff --git a/version.h b/version.h
index 3ec6ebb107..26ea62e46e 100644
--- a/version.h
+++ b/version.h
@@ -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
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index e8dbcfb91f..da87a11582 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -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;
-
- 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);
-
- 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);
- }
+ 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);
+
+ 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);
}
}