summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--eval.c16
2 files changed, 21 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index c59803f1f3..0836a354dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
@@ -18,11 +23,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.
diff --git a/eval.c b/eval.c
index ceb95e4d21..0f15c6fe5f 100644
--- a/eval.c
+++ b/eval.c
@@ -9094,13 +9094,22 @@ umethod_bind(method, recv)
VALUE method, 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));
}
@@ -9109,7 +9118,8 @@ umethod_bind(method, 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;
}