-;;; Assert that CALL is to a function of the specified TYPE. It is
-;;; assumed that the call is legal and has only constants in the
-;;; keyword positions.
-(defun assert-call-type (call type)
- (declare (type combination call) (type fun-type type))
- (derive-node-type call (fun-type-returns type))
- (let ((args (combination-args call))
- (policy (lexenv-policy (node-lexenv call))))
- (dolist (req (fun-type-required type))
- (when (null args) (return-from assert-call-type))
- (let ((arg (pop args)))
- (assert-continuation-type arg req policy)))
- (dolist (opt (fun-type-optional type))
- (when (null args) (return-from assert-call-type))
- (let ((arg (pop args)))
- (assert-continuation-type arg opt policy)))
-
- (let ((rest (fun-type-rest type)))
- (when rest
- (dolist (arg args)
- (assert-continuation-type arg rest policy))))
-
- (dolist (key (fun-type-keywords type))
- (let ((name (key-info-name key)))
- (do ((arg args (cddr arg)))
- ((null arg))
- (when (eq (continuation-value (first arg)) name)
- (assert-continuation-type
- (second arg) (key-info-type key)
- policy))))))
- (values))