X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Ffdefinition.lisp;h=a23c0e4886c31617482cc14f363e528f103733a1;hb=cee8ef591040db9a79cdd19297867672a9529051;hp=710b24cd5f7edf997411945945a6ccd9768dcff6;hpb=146ca8325e1d9e206a6c14e76442543267dbbc51;p=sbcl.git diff --git a/src/code/fdefinition.lisp b/src/code/fdefinition.lisp index 710b24c..a23c0e4 100644 --- a/src/code/fdefinition.lisp +++ b/src/code/fdefinition.lisp @@ -60,6 +60,10 @@ (setf (info :function :definition name) (make-fdefn name)) fdefn))) +(defun maybe-clobber-ftype (name) + (unless (eq :declared (info :function :where-from name)) + (clear-info :function :type name))) + ;;; Return the fdefinition of NAME, including any encapsulations. ;;; The compiler emits calls to this when someone tries to FUNCALL ;;; something. SETFable. @@ -69,6 +73,7 @@ (or (and fdefn (fdefn-fun fdefn)) (error 'undefined-function :name name)))) (defun (setf %coerce-name-to-fun) (function name) + (maybe-clobber-ftype name) (let ((fdefn (fdefinition-object name t))) (setf (fdefn-fun fdefn) function))) @@ -120,18 +125,16 @@ ;;; This is like FIND-IF, except that we do it on a compiled closure's ;;; environment. -(defun find-if-in-closure (test fun) - (declare (type function test)) - (dotimes (index (1- (get-closure-length fun))) - (let ((elt (%closure-index-ref fun index))) - (when (funcall test elt) - (return elt))))) +(defun find-if-in-closure (test closure) + (declare (closure closure)) + (do-closure-values (value closure) + (when (funcall test value) + (return value)))) ;;; Find the encapsulation info that has been closed over. (defun encapsulation-info (fun) - (and (functionp fun) - (= (widetag-of fun) sb!vm:closure-header-widetag) - (find-if-in-closure #'encapsulation-info-p fun))) + (when (closurep fun) + (find-if-in-closure #'encapsulation-info-p fun))) ;;; When removing an encapsulation, we must remember that ;;; encapsulating definitions close over a reference to the @@ -235,6 +238,7 @@ "Set NAME's global function definition." (declare (type function new-value) (optimize (safety 1))) (with-single-package-locked-error (:symbol name "setting fdefinition of ~A") + (maybe-clobber-ftype name) ;; Check for hash-table stuff. Woe onto him that mixes encapsulation ;; with this.