mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
479a3c4c8b
commit
8e8bb6c173
3 changed files with 30 additions and 2 deletions
|
@ -1,8 +1,17 @@
|
|||
Fri Jan 8 23:35:18 2010 Yusuke Endoh <mame@tsg.ne.jp>
|
||||
|
||||
* 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@tsg.ne.jp>
|
||||
|
||||
* vm_method.c (rb_alias): skip ZSUPER method when searching body of
|
||||
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@ruby-lang.org>
|
||||
|
||||
* lib/net/http, lib/net/https: move content from net/https to
|
||||
|
|
8
proc.c
8
proc.c
|
@ -894,6 +894,7 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
|
|||
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 @@ mnew(VALUE klass, VALUE obj, ID id, VALUE mclass, int scope)
|
|||
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);
|
||||
|
|
|
@ -312,4 +312,19 @@ class TestMethod < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue