なかだです。

http://mput.dip.jp/mput/?date=20051207#c03 の件のパッチです。


Index: eval.c =================================================================== RCS file: /cvs/ruby/src/ruby/eval.c,v retrieving revision 1.848 diff -U2 -p -r1.848 eval.c --- eval.c 6 Dec 2005 07:52:17 -0000 1.848 +++ eval.c 7 Dec 2005 04:47:49 -0000 @@ -8968,11 +8968,20 @@ 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)); @@ -8983,5 +8992,6 @@ umethod_bind(VALUE method, VALUE recv) *bound = *data; bound->recv = recv; - bound->rklass = CLASS_OF(recv); + bound->klass = klass; + bound->rklass = rklass; return method;
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦