summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--test/ruby/test_refinement.rb25
-rw-r--r--version.h2
-rw-r--r--vm_method.c4
4 files changed, 35 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 9332f21943..3c60c9cfec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sun Mar 1 02:30:23 2015 Seiei Higa <hanachin@gmail.com>
+
+ * 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]
+
Sun Mar 1 01:17:24 2015 Seiei Higa <hanachin@gmail.com>
* vm_method.c (rb_export_method): bail out if the original method
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 65137f0e3a..98bf9c6027 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -1181,6 +1181,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 02f9f18a28..d70d742f46 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.1.5"
#define RUBY_RELEASE_DATE "2015-03-01"
-#define RUBY_PATCHLEVEL 304
+#define RUBY_PATCHLEVEL 305
#define RUBY_RELEASE_YEAR 2015
#define RUBY_RELEASE_MONTH 3
diff --git a/vm_method.c b/vm_method.c
index 08946b9862..3748e92679 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1259,7 +1259,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))) {