]> git.eshelyaron.com Git - emacs.git/commitdiff
Make pcase pattern 'eieio' respect slot access related functions.
authorZhu Zihao <all_but_last@163.com>
Fri, 8 May 2020 09:01:56 +0000 (17:01 +0800)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 8 May 2020 15:08:02 +0000 (11:08 -0400)
* lisp/emacs-lisp/eieio.el: Make pcase pattern respect slot-missing and
slot-unbound

lisp/emacs-lisp/eieio.el

index fe2b80be01ecabb8afaa71c18689788534b948c6..999d75f79e974988f606ae8da903cf0a2b01f65d 100644 (file)
@@ -359,16 +359,13 @@ contents of field NAME is matched against PAT, or they can be of
     ;; FIXME: `pcase' does not do a good job here of sharing tests&code among
     ;; various branches.
     `(and (pred eieio-object-p)
-          (app eieio-pcase-slot-index-table ,is)
-          ,@(mapcar (lambda (field)
-                      (let* ((name (if (consp field) (car field) field))
-                             (pat (if (consp field) (cadr field) field))
-                             (i (make-symbol "index")))
-                        `(and (let (and ,i (pred natnump))
-                                (eieio-pcase-slot-index-from-index-table
-                                 ,is ',name))
-                              (app (pcase--flip aref ,i) ,pat))))
-                    fields))))
+        ,@(mapcar (lambda (field)
+                    (pcase-exhaustive field
+                      (`(,name ,pat)
+                        `(app (pcase--flip eieio-oref ',name) ,pat))
+                      ((pred symbolp)
+                       `(app (pcase--flip eieio-oref ',field) ,field))))
+                  fields))))
 \f
 ;;; Simple generators, and query functions.  None of these would do
 ;;  well embedded into an object.