all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: 28489@debbugs.gnu.org
Subject: bug#28489: Acknowledgement (27.0.50; eieio-persistent slot type validation should be a bit smarter)
Date: Tue, 26 Sep 2017 13:22:50 -0700	[thread overview]
Message-ID: <878th1i50l.fsf@ericabrahamsen.net> (raw)
In-Reply-To: <handler.28489.B.150569546424990.ack@debbugs.gnu.org> (GNU bug Tracking System's message of "Mon, 18 Sep 2017 00:45:02 +0000")

[-- Attachment #1: Type: text/plain, Size: 69 bytes --]

Here's a basic patch that does the bare minimum, and seems to work.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: orclasstypes.diff --]
[-- Type: text/x-diff, Size: 2232 bytes --]

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.

  parent reply	other threads:[~2017-09-26 20:22 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-18  0:43 bug#28489: 27.0.50; eieio-persistent slot type validation should be a bit smarter Eric Abrahamsen
     [not found] ` <handler.28489.B.150569546424990.ack@debbugs.gnu.org>
2017-09-26 20:22   ` Eric Abrahamsen [this message]
2017-09-27  0:05     ` bug#28489: Acknowledgement (27.0.50; eieio-persistent slot type validation should be a bit smarter) Noam Postavsky
2017-09-27 16:39       ` Eric Abrahamsen
2017-09-28  2:23         ` Noam Postavsky
2017-09-28  5:02           ` Eric Abrahamsen
2017-09-29  0:35             ` Noam Postavsky
2017-09-29 20:31               ` Eric Abrahamsen
2017-09-30  0:57                 ` Noam Postavsky
2017-09-30 18:05                   ` Eric Abrahamsen
2017-09-30 21:58                     ` Noam Postavsky
2017-09-30 23:30                       ` Eric Abrahamsen
2017-10-14 12:13               ` Eric Abrahamsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878th1i50l.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=28489@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.