Forwarding this here too. Note that 1.9 doesn't seem to exhibit the
same problem.

Peter

---------- Forwarded message ----------
From: Calamitas <calamitates / gmail.com>
Date: Apr 22, 2007 11:39 PM
Subject: Re: Object#method and super. Is this a bug?
To: ruby-talk / ruby-lang.org


On 4/21/07, apefan / dodgeit.com <apefan / dodgeit.com> wrote:
> Baz#boo and Baz.new.method(:boo).call dosn't produce the same result.
> Does this surprise anyone?

This got broken in 1.8.3. This is indirectly caused by the patch in
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/3672,
namely when search_iclass actually got removed afterwards. The patch
below should fix things again. I hope it doesn't break anything else.

Peter

PS: Matz, should rb_class_name really call rb_class_real? I would have
expected rb_class_name to give the module name for ICLASSes, but it
doesn't so I needed to change method_inspect as well.

--- eval.c.old  2007-04-22 22:59:13.000000000 +0200
+++ eval.c      2007-04-22 23:03:22.000000000 +0200
@@ -8966,7 +8966,6 @@
           (FL_TEST(rklass, FL_SINGLETON) || TYPE(rklass) == T_ICLASS)) {
        rklass = RCLASS(rklass)->super;
     }
-    if (TYPE(klass) == T_ICLASS) klass = RBASIC(klass)->klass;
     method = Data_Make_Struct(mklass, struct METHOD, bm_mark, free, data);
     data->klass = klass;
     data->recv = obj;
@@ -9410,7 +9409,7 @@
     VALUE method;
 {
     struct METHOD *data;
-    VALUE str;
+    VALUE str, klass;
     const char *s;
     char *sharp = "#";

@@ -9441,8 +9440,12 @@
     else {
        rb_str_buf_cat2(str, rb_class2name(data->rklass));
        if (data->rklass != data->klass) {
+            klass = data->klass;
+            if (TYPE(klass) == T_ICLASS) {
+              klass = RBASIC(klass)->klass;
+            }
            rb_str_buf_cat2(str, "(");
-           rb_str_buf_cat2(str, rb_class2name(data->klass));
+            rb_str_buf_cat2(str, rb_class2name(klass));
            rb_str_buf_cat2(str, ")");
        }
     }