1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* vm_method.c (rb_alias): skip ZSUPER method when searching body of

source method.  [ruby-dev:39760]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2010-01-08 14:10:58 +00:00
parent e0cdab5fff
commit 479a3c4c8b
3 changed files with 35 additions and 1 deletions

View file

@ -1,3 +1,8 @@
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]
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

View file

@ -85,4 +85,23 @@ class TestAlias < Test::Unit::TestCase
end
end
end
def test_alias_with_zsuper_method
c = Class.new
c.class_eval do
def foo
:ok
end
def bar
:ng
end
private :foo
end
d = Class.new(c)
d.class_eval do
public :foo
alias bar foo
end
assert_equal(:ok, d.new.bar)
end
end

View file

@ -858,7 +858,9 @@ rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_defini
void
rb_alias(VALUE klass, ID name, ID def)
{
VALUE target_klass = klass;
rb_method_entry_t *orig_me;
rb_method_flag_t flag = NOEX_UNDEF;
if (NIL_P(klass)) {
rb_raise(rb_eTypeError, "no class to make alias");
@ -869,6 +871,7 @@ rb_alias(VALUE klass, ID name, ID def)
rb_secure(4);
}
again:
orig_me = search_method(klass, def);
if (UNDEFINED_METHOD_ENTRY_P(orig_me)) {
@ -877,8 +880,15 @@ rb_alias(VALUE klass, ID name, ID def)
rb_print_undef(klass, def, 0);
}
}
if (orig_me->def->type == VM_METHOD_TYPE_ZSUPER) {
klass = RCLASS_SUPER(klass);
def = orig_me->def->original_id;
flag = orig_me->flag;
goto again;
}
rb_add_method_me(klass, name, orig_me, orig_me->flag);
if (flag == NOEX_UNDEF) flag = orig_me->flag;
rb_add_method_me(target_klass, name, orig_me, flag);
}
/*