1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

remove from original m_tbl

* vm_method.c (remove_method): remove the method from the original
  m_tbl on a prepended module.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36239 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-06-27 13:40:37 +00:00
parent d4269d7b7c
commit 3e96f56f8a
2 changed files with 10 additions and 0 deletions

View file

@ -1290,4 +1290,13 @@ class TestModule < Test::Unit::TestCase
o.singleton_class.class_eval {prepend Module.new} o.singleton_class.class_eval {prepend Module.new}
assert_equal([], o.singleton_methods) assert_equal([], o.singleton_methods)
end end
def test_prepend_remove_method
assert_raise(NameError) do
Class.new do
prepend Module.new {def foo; end}
remove_method(:foo)
end
end
end
end end

View file

@ -452,6 +452,7 @@ remove_method(VALUE klass, ID mid)
st_data_t key, data; st_data_t key, data;
rb_method_entry_t *me = 0; rb_method_entry_t *me = 0;
klass = RCLASS_ORIGIN(klass);
if (klass == rb_cObject) { if (klass == rb_cObject) {
rb_secure(4); rb_secure(4);
} }