ruby-changes:27691
From: nobu <ko1@a...>
Date: Wed, 13 Mar 2013 14:51:42 +0900 (JST)
Subject: [ruby-changes:27691] nobu:r39743 (trunk): vm_method.c: overrid flag of prepending method
nobu 2013-03-13 14:51:32 +0900 (Wed, 13 Mar 2013) New Revision: 39743 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39743 Log: vm_method.c: overrid flag of prepending method * 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] Modified files: trunk/ChangeLog trunk/test/ruby/test_module.rb trunk/vm_method.c Index: ChangeLog =================================================================== --- ChangeLog (revision 39742) +++ ChangeLog (revision 39743) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Mar 13 14:51:26 2013 Nobuyoshi Nakada <nobu@r...> + + * 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@r...> * configure.in (rm, shvar_to_cpp, unexpand_shvar): local is not Index: vm_method.c =================================================================== --- vm_method.c (revision 39742) +++ vm_method.c (revision 39743) @@ -754,7 +754,8 @@ rb_export_method(VALUE klass, ID name, r https://github.com/ruby/ruby/blob/trunk/vm_method.c#L754 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; Index: test/ruby/test_module.rb =================================================================== --- test/ruby/test_module.rb (revision 39742) +++ test/ruby/test_module.rb (revision 39743) @@ -1489,6 +1489,18 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L1489 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/