summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_module.rb9
-rw-r--r--vm_method.c1
2 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index aa48e1793c..d7a6248909 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1290,4 +1290,13 @@ class TestModule < Test::Unit::TestCase
o.singleton_class.class_eval {prepend Module.new}
assert_equal([], o.singleton_methods)
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
diff --git a/vm_method.c b/vm_method.c
index 5a7722cd67..7546a1c31c 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -452,6 +452,7 @@ remove_method(VALUE klass, ID mid)
st_data_t key, data;
rb_method_entry_t *me = 0;
+ klass = RCLASS_ORIGIN(klass);
if (klass == rb_cObject) {
rb_secure(4);
}