diff options
| -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 @@ +Sat Jan 17 16:35:59 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] + Sat Jan 17 16:16:14 2015 Nobuyoshi Nakada <nobu@ruby-lang.org> * dir.c (glob_helper): match in case-folding only if the directory diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 11077b6e4d..8553c42e18 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1165,6 +1165,20 @@ class TestRefinement < Test::Unit::TestCase end; end + def test_change_refined_new_method_visibility + assert_separately([], <<-"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.2.0" #define RUBY_RELEASE_DATE "2015-01-17" -#define RUBY_PATCHLEVEL 19 +#define RUBY_PATCHLEVEL 20 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 diff --git a/vm_method.c b/vm_method.c index 8af2198dbd..97ae64f55d 100644 --- a/vm_method.c +++ b/vm_method.c @@ -825,7 +825,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); } |
