summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-07 17:08:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-07 17:08:40 +0000
commit7479c0288ff3186073381e865a9793690720940a (patch)
tree2895b7f8bcb358a7b19c8ed23e4ee5f9f4cad5d4
parent30aede9b8b8eccdd15b6711a085b8cb25a3acbcd (diff)
downloadruby-7479c0288ff3186073381e865a9793690720940a.tar.gz
ruby-7479c0288ff3186073381e865a9793690720940a.tar.xz
ruby-7479c0288ff3186073381e865a9793690720940a.zip
* eval.c (umethod_bind): adjust invoking class for module method.
[ruby-dev:27964] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@9658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog11
-rw-r--r--eval.c16
2 files changed, 21 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index c59803f1f..0836a354d 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 ceb95e4d2..0f15c6fe5 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;
}