diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-27 07:43:57 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-27 07:43:57 +0000 |
commit | d7e152bf0607af317da8cbf6b33d8e0685686151 (patch) | |
tree | 1d104270e15e1af8ec7f909e1f30fb3b698d7e03 | |
parent | 50e48bc3aedc8ebd202de6737e5b161fe40d454d (diff) |
merge revision(s) 49182,49183: [Backport #10706]
vm_method.c: fix change refined new method visibility
* vm_method.c (rb_export_method): bail out if the original method
is undefined when the method is refined.
[ruby-core:67387] [Bug #10706]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@49423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | test/ruby/test_refinement.rb | 14 | ||||
-rw-r--r-- | version.h | 2 | ||||
-rw-r--r-- | vm_method.c | 4 |
4 files changed, 24 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Tue Jan 27 16:41:33 2015 Seiei Higa <hanachin@gmail.com> + + * vm_method.c (rb_export_method): bail out if the original method + is undefined when the method is refined. + [ruby-core:67387] [Bug #10706] + Tue Jan 27 16:27:44 2015 Eric Wong <e@80x24.org> * lib/resolv.rb: consider ENETUNREACH as ResolvTimeout diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 417059f651..a98d3332bf 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1002,6 +1002,20 @@ class TestRefinement < Test::Unit::TestCase INPUT end + def test_change_refined_new_method_visibility + assert_separately(['-W0'], <<-"end;") + bug10706 = '[ruby-core:67387] [Bug #10706]' + module RefinementBug + refine Object do + def foo + end + end + end + + assert_raise(NameError, bug10706) {private(:foo)} + end; + end + private def eval_using(mod, s) @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.0.0" #define RUBY_RELEASE_DATE "2015-01-27" -#define RUBY_PATCHLEVEL 618 +#define RUBY_PATCHLEVEL 619 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 diff --git a/vm_method.c b/vm_method.c index 0258f36d99..47223e2c22 100644 --- a/vm_method.c +++ b/vm_method.c @@ -771,7 +771,9 @@ rb_export_method(VALUE klass, ID name, rb_method_flag_t noex) me = search_method(rb_cObject, name, &defined_class); } - if (UNDEFINED_METHOD_ENTRY_P(me)) { + if (UNDEFINED_METHOD_ENTRY_P(me) || + (me->def->type == VM_METHOD_TYPE_REFINED && + UNDEFINED_METHOD_ENTRY_P(me->def->body.orig_me))) { rb_print_undef(klass, name, 0); } |