From 0ec84041118d2b84f0cdb4f3578e63aa1fae6678 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Fri, 7 Feb 2014 10:05:21 +0000 Subject: [PATCH] call NO-APPLICABLE-METHOD in the appropriate place Otherwise we end up with NO-PRIMARY-METHODs. We should only compute an EMF if there are in fact some methods, or at least that seems to be the current behaviour of SB-MOP:COMPUTE-EFFECTIVE-METHOD-FUNCTION --- signum-specializer.lisp | 5 ++++- specializable.lisp | 10 ++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/signum-specializer.lisp b/signum-specializer.lisp index a5d21fa..ab7c0de 100644 --- a/signum-specializer.lisp +++ b/signum-specializer.lisp @@ -63,7 +63,10 @@ (defmethod fact ((n (signum 0))) 1) (defmethod fact ((n (signum 1))) (* n (fact (1- n)))) (assert (eql (fact 6) 720)) - (assert (eql (fact 6.0) 720.0)))) + (assert (eql (fact 6.0) 720.0)) + (defmethod no-applicable-method ((gf (eql #'fact)) &rest args) + 'gotcha) + (assert (eql (fact -6) 'gotcha)))) (eval '(progn diff --git a/specializable.lisp b/specializable.lisp index ebe4794..1df14d4 100644 --- a/specializable.lisp +++ b/specializable.lisp @@ -155,10 +155,12 @@ args)))) (defun compute-effective-method-function (gf methods) - (let* ((mc (sb-mop:generic-function-method-combination gf)) - (sb-pcl::*applicable-methods* methods) - (em (sb-mop:compute-effective-method gf mc methods))) - (sb-pcl::make-effective-method-function gf em))) + (if (null methods) + (lambda (&rest args) (apply #'no-applicable-method gf args)) + (let* ((mc (sb-mop:generic-function-method-combination gf)) + (sb-pcl::*applicable-methods* methods) + (em (sb-mop:compute-effective-method gf mc methods))) + (sb-pcl::make-effective-method-function gf em)))) ;; new, not in closette (defgeneric generalizer-of-using-class (generic-function object)) -- 2.30.2