- (let* ((dtype (node-derived-type call))
- (return-type (fun-type-returns type))
- (out-type dtype))
- (multiple-value-bind (int win) (funcall result-test out-type return-type)
- (cond ((not win)
- (note-unwinnage "can't tell whether the result is a ~S"
- (type-specifier return-type)))
- ((not int)
- (note-lossage "The result is a ~S, not a ~S."
- (type-specifier out-type)
- (type-specifier return-type)))))))
+ (when result-test
+ (let* ((dtype (node-derived-type call))
+ (out-type (or
+ (binding* ((lvar (node-lvar call) :exit-if-null)
+ (dest (lvar-dest lvar)))
+ (when (and (cast-p dest)
+ (eq (cast-type-to-check dest) *wild-type*)
+ (immediately-used-p lvar call))
+ (values-type-intersection
+ dtype (cast-asserted-type dest))))
+ dtype))
+ (return-type (fun-type-returns type)))
+ (multiple-value-bind (int win) (funcall result-test out-type return-type)
+ (cond ((not win)
+ (note-unwinnage "can't tell whether the result is a ~S"
+ (type-specifier return-type)))
+ ((not int)
+ (note-lossage "The result is a ~S, not a ~S."
+ (type-specifier out-type)
+ (type-specifier return-type))))))))