diff --git a/lisp/emacs-lisp/eieio-base.el b/lisp/emacs-lisp/eieio-base.el index 6b39b4f262..361c1a4eb9 100644 --- a/lisp/emacs-lisp/eieio-base.el +++ b/lisp/emacs-lisp/eieio-base.el @@ -308,14 +308,6 @@ eieio-persistent-validate/fix-slot-value (= (length proposed-value) 1)) nil) - ;; We have a slot with a single object that can be - ;; saved here. Recurse and evaluate that - ;; sub-object. - ((and classtype (class-p classtype) - (child-of-class-p (car proposed-value) classtype)) - (eieio-persistent-convert-list-to-object - proposed-value)) - ;; List of object constructors. ((and (eq (car proposed-value) 'list) ;; 2nd item is a list. @@ -346,6 +338,16 @@ eieio-persistent-validate/fix-slot-value objlist)) ;; return the list of objects ... reversed. (nreverse objlist))) + ;; We have a slot with a single object that can be + ;; saved here. Recurse and evaluate that + ;; sub-object. + ((and classtype + (seq-some + (lambda (c-type) + (child-of-class-p (car proposed-value) c-type)) + (if (listp classtype) classtype (list classtype)))) + (eieio-persistent-convert-list-to-object + proposed-value)) (t proposed-value)))) @@ -359,7 +361,7 @@ eieio-persistent-validate/fix-slot-value ) (defun eieio-persistent-slot-type-is-class-p (type) - "Return the class referred to in TYPE. + "Return the class or classes referred to in TYPE. If no class is referenced there, then return nil." (cond ((class-p type) ;; If the type is a class, then return it. @@ -402,13 +404,9 @@ eieio-persistent-slot-type-is-class-p type)) ((eq (car-safe type) 'or) - ;; If type is a list, and is an or, it is possibly something - ;; like (or null myclass), so check for that. - (let ((ans nil)) - (dolist (subtype (cdr type)) - (setq ans (eieio-persistent-slot-type-is-class-p - subtype))) - ans)) + ;; If type is a list, and is an or, it is possible that + ;; multiple classes are acceptable, find them all. + (seq-filter (lambda (elt) (class-p elt)) (cdr type))) (t ;; No match, not a class.