[macruby-changes] [4806] MacRuby/trunk/dispatcher.cpp

source_changes at macosforge.org source_changes at macosforge.org
Mon Oct 18 21:37:16 PDT 2010


Revision: 4806
          http://trac.macosforge.org/projects/ruby/changeset/4806
Author:   lsansonetti at apple.com
Date:     2010-10-18 21:37:15 -0700 (Mon, 18 Oct 2010)
Log Message:
-----------
fix a bug in the super dispatch when we try to super call a method under the same selector as the current one but on a receiver from a totally different class hierarchy

Modified Paths:
--------------
    MacRuby/trunk/dispatcher.cpp

Modified: MacRuby/trunk/dispatcher.cpp
===================================================================
--- MacRuby/trunk/dispatcher.cpp	2010-10-19 04:34:43 UTC (rev 4805)
+++ MacRuby/trunk/dispatcher.cpp	2010-10-19 04:37:15 UTC (rev 4806)
@@ -608,6 +608,25 @@
 		current_super_sel = sel;
 		current_super_class = klass;
 	    }
+	    else {
+		// Let's make sure the current_super_class is valid before
+		// using it; we check this by verifying that it's a real
+		// super class of the current class, as we may be calling
+		// a super method of the same name but on a totally different
+		// class hierarchy.
+		Class k = klass;
+		bool current_super_class_ok = false;
+		while (k != NULL) {
+		    if (k == current_super_class) {
+			current_super_class_ok = true;
+			break;
+		    }
+		    k = class_getSuperclass(k);
+		}
+		if (!current_super_class_ok) {
+		    current_super_class = klass;
+		}
+	    }
 	    method = rb_vm_super_lookup(current_super_class, sel,
 		    &current_super_class);
 	}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101018/0200dcde/attachment-0001.html>


More information about the macruby-changes mailing list