- (let ((fun (or function (fdefinition name))))
- (multiple-value-bind (ftype from)
- (if function
- (values (%fun-type function) :derived)
- (let ((ctype (info :function :type name)))
- (values (when ctype (type-specifier ctype))
- (when ctype
- ;; Ensure lazy pickup of information
- ;; from methods.
- (sb-c::maybe-update-info-for-gf name)
- (ecase (info :function :where-from name)
- (:declared :declared)
- ;; This is hopefully clearer to users
- ((:defined-method :defined) :derived))))))
- (if (typep fun 'standard-generic-function)
- (values fun
- "a generic function"
- (sb-mop:generic-function-lambda-list fun)
- ftype
- from
- nil
- (or (sb-mop:generic-function-methods fun)
- :none))
- (values fun
- (if (compiled-function-p fun)
- "a compiled function"
- "an interpreted function")
- (%fun-lambda-list fun)
- ftype
- from
- (unless function
- (cons
- (info :function :inlinep name)
- (info :function :inline-expansion-designator name)))))))))
+ (let* ((fun (or function (fdefinition name)))
+ (derived-type (and function
+ (%fun-type function)))
+ (legal-name-p (legal-fun-name-p name))
+ (ctype (and legal-name-p
+ (info :function :type name)))
+ (type (and ctype (type-specifier ctype)))
+ (from (and legal-name-p
+ (info :function :where-from name)))
+ declared-type)
+ ;; Ensure lazy pickup of information
+ ;; from methods.
+ (when legal-name-p
+ (sb-c::maybe-update-info-for-gf name))
+ (cond ((not type))
+ ((eq from :declared)
+ (setf declared-type type))
+ ((and (not derived-type)
+ (member from '(:defined-method :defined)))
+ (setf derived-type type)))
+ (unless derived-type
+ (setf derived-type (%fun-type fun)))
+ (if (typep fun 'standard-generic-function)
+ (values fun
+ "a generic function"
+ (sb-mop:generic-function-lambda-list fun)
+ derived-type
+ declared-type
+ nil
+ (or (sb-mop:generic-function-methods fun)
+ :none))
+ (values fun
+ (if (compiled-function-p fun)
+ "a compiled function"
+ "an interpreted function")
+ (%fun-lambda-list fun)
+ derived-type
+ declared-type
+ (cons
+ (info :function :inlinep name)
+ (info :function :inline-expansion-designator
+ name)))))))