From 1a59bf4b4767ab7a893d1c665e41cc2c8fb2d221 Mon Sep 17 00:00:00 2001 From: Andrea Corallo Date: Wed, 10 Apr 2024 18:15:12 +0200 Subject: [PATCH] * lisp/emacs-lisp/comp-cstr.el (comp-cstr-type-p): New function. (cherry picked from commit ee03a73375796feea94bb066cff7d7de680cae32) --- lisp/emacs-lisp/comp-cstr.el | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lisp/emacs-lisp/comp-cstr.el b/lisp/emacs-lisp/comp-cstr.el index d7d3b12e148..adbbaa24a99 100644 --- a/lisp/emacs-lisp/comp-cstr.el +++ b/lisp/emacs-lisp/comp-cstr.el @@ -940,6 +940,17 @@ Non memoized version of `comp-cstr-intersection-no-mem'." (null (neg cstr)) (equal (typeset cstr) '(cons))))) +(define-inline comp-cstr-type-p (cstr type) + "Return t if CSTR is certainly of type TYPE." + (if-let ((pred (get type 'cl-deftype-satisfies))) + (with-comp-cstr-accessors + (and (null (range cstr)) + (null (neg cstr)) + (and (or (null (typeset cstr)) + (equal (typeset cstr) `(,type))) + (cl-every pred (valset cstr))))) + (error "Unknown predicate for type %s" type))) + ;; Move to comp.el? (defsubst comp-cstr-cl-tag-p (cstr) "Return non-nil if CSTR is a CL tag." -- 2.39.5