mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval.c (umethod_bind): adjust invoking class for module method.
[ruby-dev:27964] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
074313aed9
commit
949f6fe394
2 changed files with 21 additions and 6 deletions
|
@ -1,3 +1,8 @@
|
|||
Thu Dec 8 02:07:19 2005 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* eval.c (umethod_bind): adjust invoking class for module method.
|
||||
[ruby-dev:27964]
|
||||
|
||||
Thu Dec 8 00:40:52 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* eval.c (call_trace_func): klass parameter should be a
|
||||
|
|
16
eval.c
16
eval.c
|
@ -8967,13 +8967,22 @@ static VALUE
|
|||
umethod_bind(VALUE method, VALUE recv)
|
||||
{
|
||||
struct METHOD *data, *bound;
|
||||
VALUE rklass = CLASS_OF(recv), klass = rklass;
|
||||
|
||||
Data_Get_Struct(method, struct METHOD, data);
|
||||
if (data->rklass != CLASS_OF(recv)) {
|
||||
if (data->rklass != rklass) {
|
||||
if (FL_TEST(data->rklass, FL_SINGLETON)) {
|
||||
rb_raise(rb_eTypeError, "singleton method called for a different object");
|
||||
}
|
||||
if(!rb_obj_is_kind_of(recv, data->rklass)) {
|
||||
if (TYPE(data->rklass) == T_MODULE) {
|
||||
st_table *m_tbl = RCLASS(data->rklass)->m_tbl;
|
||||
while (RCLASS(rklass)->m_tbl != m_tbl) {
|
||||
rklass = RCLASS(rklass)->super;
|
||||
if (!rklass) goto not_instace;
|
||||
}
|
||||
}
|
||||
else if (!rb_obj_is_kind_of(recv, data->rklass)) {
|
||||
not_instace:
|
||||
rb_raise(rb_eTypeError, "bind argument must be an instance of %s",
|
||||
rb_class2name(data->rklass));
|
||||
}
|
||||
|
@ -8982,7 +8991,8 @@ umethod_bind(VALUE method, VALUE recv)
|
|||
method = Data_Make_Struct(rb_cMethod,struct METHOD,bm_mark,free,bound);
|
||||
*bound = *data;
|
||||
bound->recv = recv;
|
||||
bound->rklass = CLASS_OF(recv);
|
||||
bound->klass = klass;
|
||||
bound->rklass = rklass;
|
||||
|
||||
return method;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue