mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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_3@58174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
648ee72d18
commit
f8e37f5771
3 changed files with 24 additions and 2 deletions
|
@ -1417,6 +1417,25 @@ class TestRefinement < Test::Unit::TestCase
|
|||
INPUT
|
||||
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)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#define RUBY_VERSION "2.3.3"
|
||||
#define RUBY_RELEASE_DATE "2017-03-28"
|
||||
#define RUBY_PATCHLEVEL 283
|
||||
#define RUBY_PATCHLEVEL 284
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2017
|
||||
#define RUBY_RELEASE_MONTH 3
|
||||
|
|
|
@ -1166,7 +1166,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");
|
||||
|
@ -1177,6 +1177,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);
|
||||
}
|
||||
|
||||
if (UNDEFINED_METHOD_ENTRY_P(me) ||
|
||||
UNDEFINED_REFINED_METHOD_P(me->def)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue