From 38921417228bcf683ed5e9aee12765a1dc19be0c Mon Sep 17 00:00:00 2001 From: naruse Date: Sat, 17 Jan 2015 15:53:53 +0000 Subject: [PATCH] merge revision(s) 49221: [Backport #10731] * vm_method.c (rb_alias): raise a NameError when creating alias to a refined method if the original method of the refined method is not defined. [ruby-core:67523] [Bug #10731] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@49311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ test/ruby/test_refinement.rb | 25 +++++++++++++++++++++++++ version.h | 6 +++--- vm_method.c | 4 +++- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 27a3fdaac2..ec0e7783bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sun Jan 18 00:53:38 2015 Seiei Higa + + * vm_method.c (rb_alias): raise a NameError when creating alias to + a refined method if the original method of the refined method is + not defined. [ruby-core:67523] [Bug #10731] + Sat Jan 17 22:25:50 2015 Nobuyoshi Nakada * dir.c (need_normalization): not only HFS+, CIFS (SMB) is also diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb index 8553c42e18..41d3f36636 100644 --- a/test/ruby/test_refinement.rb +++ b/test/ruby/test_refinement.rb @@ -1179,6 +1179,31 @@ class TestRefinement < Test::Unit::TestCase end; end + def test_alias_refined_method + assert_separately([], <<-"end;") + bug10731 = '[ruby-core:67523] [Bug #10731]' + + class C + end + + module RefinementBug + refine C do + def foo + end + + def bar + end + end + end + + assert_raise(NameError, bug10731) do + class C + alias foo bar + end + end + end; + end + private def eval_using(mod, s) diff --git a/version.h b/version.h index 4d9441c24a..5c0ed41e0c 100644 --- a/version.h +++ b/version.h @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.2.0" -#define RUBY_RELEASE_DATE "2015-01-17" -#define RUBY_PATCHLEVEL 24 +#define RUBY_RELEASE_DATE "2015-01-18" +#define RUBY_PATCHLEVEL 25 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 -#define RUBY_RELEASE_DAY 17 +#define RUBY_RELEASE_DAY 18 #include "ruby/version.h" diff --git a/vm_method.c b/vm_method.c index 97ae64f55d..e93bb71b4e 100644 --- a/vm_method.c +++ b/vm_method.c @@ -1273,7 +1273,9 @@ rb_alias(VALUE klass, ID name, ID def) again: orig_me = search_method(klass, def, &defined_class); - if (UNDEFINED_METHOD_ENTRY_P(orig_me)) { + if (UNDEFINED_METHOD_ENTRY_P(orig_me) || + (orig_me->def->type == VM_METHOD_TYPE_REFINED && + UNDEFINED_METHOD_ENTRY_P(orig_me->def->body.orig_me))) { if ((!RB_TYPE_P(klass, T_MODULE)) || (orig_me = search_method(rb_cObject, def, 0), UNDEFINED_METHOD_ENTRY_P(orig_me))) {