Revision
3815
Author
lsansonetti@apple.com
Date
2010-03-18 19:09:47 -0700 (Thu, 18 Mar 2010)

Log Message

when dispatching a custom #respond_to? method, do not pass the second optional argument in case the arity is incompatible

Modified Paths

Diff

Modified: MacRuby/trunk/dispatcher.cpp (3814 => 3815)


--- MacRuby/trunk/dispatcher.cpp	2010-03-18 23:21:52 UTC (rev 3814)
+++ MacRuby/trunk/dispatcher.cpp	2010-03-19 02:09:47 UTC (rev 3815)
@@ -1956,7 +1956,15 @@
 	int n = 0;
 	args[n++] = ID2SYM(rb_intern(sel_getName(sel)));
 	if (priv) {
-	    args[n++] = Qtrue;
+	    rb_vm_method_node_t *node = method_node_get(imp);
+	    if (node != NULL
+		    && (2 < node->arity.min
+			|| (node->arity.max != -1 && 2 > node->arity.max))) {
+		// Do nothing, custom respond_to? method incompatible arity.
+	    }
+	    else {
+		args[n++] = Qtrue;
+	    }
 	}
 	return rb_vm_call(obj, selRespondTo, n, args, false) == Qtrue;
     }