Function: comp--normalize-typeset0

comp--normalize-typeset0 is a byte-compiled function defined in comp-cstr.el.gz.

Signature

(comp--normalize-typeset0 TYPESET)

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/comp-cstr.el.gz
(defun comp--normalize-typeset0 (typeset)
  ;; For every type search its supertypes.  If all the subtypes of a
  ;; supertype are presents remove all of them, add the identified
  ;; supertype and restart.
  ;; FIXME: The intention is to return a 100% equivalent but simpler
  ;; typeset, but this is only the case when the supertype is abstract
  ;; and "final/closed" (i.e. can't have new subtypes).
  (when typeset
    (while (eq 'restart
               (cl-loop
                named main
                for sup in (cl-remove-duplicates
                            (apply #'append
                                   (mapcar #'comp--direct-supertypes typeset)))
                for subs = (comp--direct-subtypes sup)
                when (and (length> subs 1) ;; If there's only one sub do
                                           ;; nothing as we want to
                                           ;; return the most specific
                                           ;; type.
                          (cl-every (lambda (sub)
                                      (cl-some (lambda (type)
                                                 (comp-subtype-p sub type))
                                               typeset))
                                    subs))
                do (progn
                     (setq typeset (cons sup (cl-set-difference typeset subs)))
                     (cl-return-from main 'restart)))))
    typeset))