From 5b43e28a5a9f0fcdefc2132840492e2e382876c6 Mon Sep 17 00:00:00 2001 From: Christophe Rhodes Date: Thu, 21 Aug 2003 11:38:41 +0000 Subject: [PATCH] 0.8.2.52: Partial fix for method definition protocol ... ANSI in its wisdom saith that the mere addition of a bogus method to a generic function is not cause for signalling an error. Signal a warning instead, and defer the error to when the function is called. Factor out common testing code into a sourceable script, and adjust the clos tests to reflect this new interpretation --- NEWS | 4 ++ src/pcl/dfun.lisp | 20 +++++---- src/pcl/methods.lisp | 27 ++++++++++++ tests/clos.test.sh | 59 ++------------------------ tests/compiler.test.sh | 99 +------------------------------------------ tests/expect.sh | 102 +++++++++++++++++++++++++++++++++++++++++++++ tests/threads.impure.lisp | 3 ++ version.lisp-expr | 2 +- 8 files changed, 153 insertions(+), 163 deletions(-) create mode 100644 tests/expect.sh diff --git a/NEWS b/NEWS index c55253a..7b8d526 100644 --- a/NEWS +++ b/NEWS @@ -1989,6 +1989,10 @@ changes in sbcl-0.8.3 relative to sbcl-0.8.2: ** ASSOC now ignores NIL elements in an alist. ** CEILING now gives the right answer with MOST-NEGATIVE-FIXNUM and (1+ MOST-POSITIVE-FIXNUM) answers. + ** The addition of a method with invalid qualifiers to a generic + function does not cause an error to be signalled immediately; + a warning is signalled, and the error is generated only on + calling the generic function. planned incompatible changes in 0.8.x: * (not done yet, but planned:) When the profiling interface settles diff --git a/src/pcl/dfun.lisp b/src/pcl/dfun.lisp index 2acc37e..d51705b 100644 --- a/src/pcl/dfun.lisp +++ b/src/pcl/dfun.lisp @@ -763,17 +763,19 @@ Except see also BREAK-VICIOUS-METACIRCLE. -- CSR, 2003-05-28 ;;; considered as state transitions. (defvar *lazy-dfun-compute-p* t) (defvar *early-p* nil) +(defvar *max-emf-precomputation-methods* 0) (defun finalize-specializers (gf) - (let ((all-finalized t)) - (dolist (method (generic-function-methods gf)) - (dolist (specializer (method-specializers method)) - (when (and (classp specializer) - (not (class-finalized-p specializer))) - (if (class-has-a-forward-referenced-superclass-p specializer) - (setq all-finalized nil) - (finalize-inheritance specializer))))) - all-finalized)) + (let ((methods (generic-function-methods gf))) + (when (< (length methods) *max-emf-precomputation-methods*) + (let ((all-finalized t)) + (dolist (method methods all-finalized) + (dolist (specializer (method-specializers method)) + (when (and (classp specializer) + (not (class-finalized-p specializer))) + (if (class-has-a-forward-referenced-superclass-p specializer) + (setq all-finalized nil) + (finalize-inheritance specializer))))))))) (defun make-initial-dfun (gf) (let ((initial-dfun diff --git a/src/pcl/methods.lisp b/src/pcl/methods.lisp index 855c907..ab5110e 100644 --- a/src/pcl/methods.lisp +++ b/src/pcl/methods.lisp @@ -494,6 +494,33 @@ (setq remove-again-p nil)) (when remove-again-p (remove-method generic-function method)))) + + ;; KLUDGE II: ANSI saith that it is not an error to add a + ;; method with invalid qualifiers to a generic function of the + ;; wrong kind; it's only an error at generic function + ;; invocation time; I dunno what the rationale was, and it + ;; sucks. Nevertheless, it's probably a programmer error, so + ;; let's warn anyway. -- CSR, 2003-08-20 + (let ((mc (generic-function-method-combination generic-functioN))) + (cond + ((eq mc *standard-method-combination*) + (when (and qualifiers + (or (cdr qualifiers) + (not (memq (car qualifiers) + '(:around :before :after))))) + (warn "~@" + method qualifiers))) + ((short-method-combination-p mc) + (let ((mc-name (method-combination-type mc))) + (when (or (null qualifiers) + (cdr qualifiers) + (and (neq (car qualifiers) :around) + (neq (car qualifiers) mc-name))) + (warn "~@" + mc-name method qualifiers)))))) + (unless skip-dfun-update-p (update-ctors 'add-method :generic-function generic-function diff --git a/tests/clos.test.sh b/tests/clos.test.sh index 65dd5d8..174fceb 100644 --- a/tests/clos.test.sh +++ b/tests/clos.test.sh @@ -11,61 +11,7 @@ # absolutely no warranty. See the COPYING and CREDITS files for # more information. -# Check that compiling and loading the file $1 generates an error -# at load time; also that just loading it directly (into the -# interpreter) generates an error. -expect_load_error () -{ - # Test compiling and loading. - $SBCL < $tmpfilename < $tmpfilename < $tmpfilename <