1
0
Fork 0
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:
nobu 2005-12-07 17:08:40 +00:00
parent 074313aed9
commit 949f6fe394
2 changed files with 21 additions and 6 deletions

View file

@ -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
@ -27,11 +32,11 @@ Wed Dec 7 01:02:04 2005 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
* ext/tk/README.macosx-aqua: [new document] tips to avoid the known
bug on platform specific dialogs of Tcl/Tk Aqua on MacOS X.
* ext/tk/tcltklib.c: fix bug on switching threads and waiting on the
deleted interpreter on vwait and tkwait command.
* ext/tk/tcltklib.c: fix bug on switching threads and waiting on the
deleted interpreter on vwait and tkwait command.
* ext/tk/lib/multi-tk.rb: kill the meaningless loop for the deleted Tk
interpreter.
interpreter.
* ext/tk/sample/demos-jp/image3.rb: [bug fix] wrong argument.

16
eval.c
View file

@ -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;
}