Remove implicit type declarations in DEFMETHOD because the arguments to the function may be changed by the body itself.

This commit is contained in:
Juan Jose Garcia Ripoll 2012-02-16 23:23:15 +01:00
parent 1628fe2781
commit 70b3b2635e

View file

@ -26,6 +26,10 @@
;;;
(defparameter *next-methods* nil)
;;; Add type declarations for the arguments of a METHOD. This implies
;;; copying the method arguments because the arguments may be modified.
(defparameter *add-method-argument-declarations* nil)
;;; ----------------------------------------------------------------------
;;; DEFMETHOD
@ -70,12 +74,15 @@
'(&allow-other-keys)
(and x (subseq lambda-list x))
nil))))
(let* ((class-declarations
(nconc (loop for name in required-parameters
for type in specializers
when (and (not (eq type t)) (symbolp type))
nconc `((type ,type ,name)
(si::no-check-type ,name)))
(let* ((copied-variables '())
(class-declarations
(nconc (when *add-method-argument-declarations*
(loop for name in required-parameters
for type in specializers
when (and (not (eq type t)) (symbolp type))
do (push `(,name ,name) copied-variables) and
nconc `((type ,type ,name)
(si::no-check-type ,name))))
(cdar declarations)))
(method-lambda
;; Remove the documentation string and insert the
@ -89,10 +96,6 @@
,lambda-list
,@(and class-declarations `((declare ,@class-declarations)))
,@real-body))
(aux-bindings ()) ; Suffice to say that &aux is one of
; damndest things to have put in a
; language.
(plist ()))
(multiple-value-bind (call-next-method-p next-method-p-p in-closure-p)
(walk-method-lambda method-lambda required-parameters env)
@ -121,7 +124,9 @@
`#'(ext::lambda-block ,generic-function-name
,lambda-list
,@(and class-declarations `((declare ,@class-declarations)))
,@real-body)
,@(if copied-variables
`((let* ,copied-variables ,@real-body))
real-body))
documentation
plist)))))