summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--test/ruby/test_module.rb12
-rw-r--r--vm_method.c3
3 files changed, 20 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index ca86509297..74693e1e05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Mar 13 14:51:26 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * vm_method.c (rb_export_method): directly override the flag of method
+ defined in prepending class too, not adding zsuper entry.
+ [ruby-core:53106] [Bug #8005]
+
Wed Mar 13 13:06:26 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* configure.in (rm, shvar_to_cpp, unexpand_shvar): local is not
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index af3150b8a0..fa7484b10a 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -1489,6 +1489,18 @@ class TestModule < Test::Unit::TestCase
assert_equal(0, 1 / 2)
end
+ def test_prepend_visibility
+ bug8005 = '[ruby-core:53106] [Bug #8005]'
+ c = Class.new do
+ prepend Module.new {}
+ def foo() end
+ protected :foo
+ end
+ a = c.new
+ assert_respond_to a, [:foo, true]
+ assert_nothing_raised(NoMethodError) {a.send :foo}
+ end
+
def test_class_variables
m = Module.new
m.class_variable_set(:@@foo, 1)
diff --git a/vm_method.c b/vm_method.c
index effc4a453a..6d0865f9d8 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -754,7 +754,8 @@ rb_export_method(VALUE klass, ID name, rb_method_flag_t noex)
if (me->flag != noex) {
rb_vm_check_redefinition_opt_method(me, klass);
- if (klass == defined_class) {
+ if (klass == defined_class ||
+ RCLASS_ORIGIN(klass) == defined_class) {
me->flag = noex;
if (me->def->type == VM_METHOD_TYPE_REFINED) {
me->def->body.orig_me->flag = noex;