Function: register--get-method-type
register--get-method-type is a byte-compiled function defined in
register.el.gz.
Signature
(register--get-method-type VAL GENFUN &optional OTHER-ARGS-TYPE)
Source Code
;; Defined in /usr/src/emacs/lisp/register.el.gz
(defun register--get-method-type (val genfun &optional other-args-type)
;; Try and return the specializer used in the most specific method
;; applicable to argument VAL in generic function GENFUN.
;; VAL is assumed to be the first argument and OTHER-ARGS-TYPE
;; is a list of types for the other arguments.
;; Go through all the types of VAL (from most specific to least specific)
;; and return the first for which we can find a method with that
;; type as specializer.
;; FIXME: This is ad-hoc and does not handle all possible cases.
;; We should instead do what `cl-generic' does during dispatch,
;; i.e. get the set of generalizers used for the first arg of this generic
;; function, use them to compute the TAGs corresponding to VAL (which
;; we approximate here in TYPE) and then use those TAGs to compute the
;; corresponding set of specializers (which we approximate here in TYPES),
;; then look for the best matching method.
(let* ((type (or (oclosure-type val) (cl-type-of val)))
(types (cl--class-allparents (cl--find-class type))))
(if (eq type 'cons) (push `(head ,(car val)) types))
(push `(eql ',val) types)
(while (and types (not (cl-find-method genfun nil
(cons (car types) other-args-type))))
(setq types (cdr types)))
(car types)))