summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-25 18:42:37 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-25 18:42:37 +0000
commitd5b08a46d0ef0a4a6e28077fca25c71e4791a0be (patch)
tree7ce6073daf206dbba2e5b3f7649693c50d4d9809
parent950758b028049141a917a28f7232a3f05ee6b46e (diff)
merge revision(s) 57362: [Backport #13096]
vm_method.c: resolve refined method to undef * vm_method.c (rb_undef): resolve the method entry which refines a prepended method entry. [ruby-core:78944] [Bug #13096] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@58126 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_refinement.rb19
-rw-r--r--version.h2
-rw-r--r--vm_method.c5
3 files changed, 24 insertions, 2 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 557dc385aa..5b0969f218 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -1387,6 +1387,25 @@ class TestRefinement < Test::Unit::TestCase
:foo, bug10826)
end
+ def test_undef_prepended_method
+ bug13096 = '[ruby-core:78944] [Bug #13096]'
+ klass = EnvUtil.labeled_class("X") do
+ def foo; end
+ end
+ klass.prepend(Module.new)
+ ext = EnvUtil.labeled_module("Ext") do
+ refine klass do
+ def foo
+ end
+ end
+ end
+ assert_nothing_raised(NameError, bug13096) do
+ klass.class_eval do
+ undef :foo
+ end
+ end
+ end
+
def test_call_refined_method_in_duplicate_module
bug10885 = '[ruby-dev:48878]'
assert_in_out_err([], <<-INPUT, [], [], bug10885)
diff --git a/version.h b/version.h
index 2b91a9ec14..3f27fab001 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.2.7"
#define RUBY_RELEASE_DATE "2017-03-26"
-#define RUBY_PATCHLEVEL 458
+#define RUBY_PATCHLEVEL 459
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 3
diff --git a/vm_method.c b/vm_method.c
index 3159b22fa2..71c1e0a43a 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -923,7 +923,7 @@ rb_attr(VALUE klass, ID id, int read, int write, int ex)
void
rb_undef(VALUE klass, ID id)
{
- rb_method_entry_t *me;
+ const rb_method_entry_t *me;
if (NIL_P(klass)) {
rb_raise(rb_eTypeError, "no class to undef method");
@@ -934,6 +934,9 @@ rb_undef(VALUE klass, ID id)
}
me = search_method(klass, id, 0);
+ if (me && me->def->type == VM_METHOD_TYPE_REFINED) {
+ me = rb_resolve_refined_method(Qnil, me, NULL);
+ }
if (UNDEFINED_METHOD_ENTRY_P(me) ||
UNDEFINED_REFINED_METHOD_P(me->def)) {