ruby-changes:14426
From: mame <ko1@a...>
Date: Fri, 8 Jan 2010 23:42:14 +0900 (JST)
Subject: [ruby-changes:14426] Ruby:r26256 (trunk): * proc.c (mnew): don't check visibility of method body if public
mame 2010-01-08 23:40:38 +0900 (Fri, 08 Jan 2010) New Revision: 26256 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26256 Log: * proc.c (mnew): don't check visibility of method body if public ZSUPER method is found. [ruby-dev:39767] * test/ruby/test_method.rb: add a test for above. Modified files: trunk/ChangeLog trunk/proc.c trunk/test/ruby/test_method.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 26255) +++ ChangeLog (revision 26256) @@ -1,3 +1,10 @@ +Fri Jan 8 23:35:18 2010 Yusuke Endoh <mame@t...> + + * proc.c (mnew): don't check visibility of method body if public + ZSUPER method is found. [ruby-dev:39767] + + * test/ruby/test_method.rb: add a test for above. + Fri Jan 8 22:59:40 2010 Yusuke Endoh <mame@t...> * vm_method.c (rb_alias): skip ZSUPER method when searching body of @@ -3,4 +10,6 @@ source method. [ruby-dev:39760] + * test/ruby/test_alias.rb: add a test for above. + Fri Jan 8 21:15:21 2010 NARUSE, Yui <naruse@r...> Index: proc.c =================================================================== --- proc.c (revision 26255) +++ proc.c (revision 26256) @@ -894,6 +894,7 @@ struct METHOD *data; rb_method_entry_t *me, meb; rb_method_definition_t *def = 0; + rb_method_flag_t flag = NOEX_UNDEF; again: me = rb_method_entry(klass, id); @@ -921,8 +922,11 @@ rb_print_undef(klass, id, 0); } def = me->def; - if (scope && (me->flag & NOEX_MASK) != NOEX_PUBLIC) { - rb_print_undef(rclass, def->original_id, (int)(me->flag & NOEX_MASK)); + if (flag == NOEX_UNDEF) { + flag = me->flag; + if (scope && (flag & NOEX_MASK) != NOEX_PUBLIC) { + rb_print_undef(rclass, def->original_id, (int)(flag & NOEX_MASK)); + } } if (def && def->type == VM_METHOD_TYPE_ZSUPER) { klass = RCLASS_SUPER(me->klass); Index: test/ruby/test_method.rb =================================================================== --- test/ruby/test_method.rb (revision 26255) +++ test/ruby/test_method.rb (revision 26256) @@ -312,4 +312,19 @@ assert_equal([[:req, :a], [:opt, :b], [:rest, :c], [:req, :d], [:block, :e]], self.class.instance_method(:pmo7).parameters) assert_equal([[:req], [:block, :b]], self.class.instance_method(:pma1).parameters) end + + def test_public_method_with_zsuper_method + c = Class.new + c.class_eval do + def foo + :ok + end + private :foo + end + d = Class.new(c) + d.class_eval do + public :foo + end + assert_equal(:ok, d.new.public_method(:foo).call) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/