summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/eieio.el
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2019-05-27 19:05:56 -0400
committerNoam Postavsky <npostavs@gmail.com>2019-05-30 18:46:07 -0400
commit5f01af6c8e0f7355f7a99a80ff32369071f65eda (patch)
treef65280a7140425f0db5ad19782c699a0def2bed5 /lisp/emacs-lisp/eieio.el
parent4b24b0185d910d756e85ecdc30f49c414577050e (diff)
downloademacs-5f01af6c8e0f7355f7a99a80ff32369071f65eda.tar.gz
Use plain symbols for eieio type descriptors (Bug#29220)
Since Emacs 26, eieio objects use a class record (with circular references) as the type descriptor of the object record. This causes problems when reading back an object from a string, because the class record is not `eq' to the canonical one (which means that read objects don't satisfy the foo-p predicate). * lisp/emacs-lisp/eieio.el (make-instance): As a (partial) fix, set the record's type descriptor to a plain symbol for the type descriptor when eieio-backward-compatibility is non-nil (the default). * lisp/emacs-lisp/eieio-core.el (eieio--object-class): Call eieio--class-object on the type tag when eieio-backward-compatibility is non-nil. (eieio-object-p): Use eieio--object-class instead of eieio--object-class-tag. * test/lisp/emacs-lisp/eieio-tests/eieio-test-persist.el (eieio-test-persist-hash-and-vector) (eieio-test-persist-interior-lists): Make into functions. (eieio-persist-hash-and-vector-backward-compatibility) (eieio-persist-hash-and-vector-no-backward-compatibility) (eieio-test-persist-interior-lists-backward-compatibility) (eieio-test-persist-interior-lists-no-backward-compatibility): New tests which call them, eieio-backward-compatibility let-bound.
Diffstat (limited to 'lisp/emacs-lisp/eieio.el')
-rw-r--r--lisp/emacs-lisp/eieio.el3
1 files changed, 3 insertions, 0 deletions
diff --git a/lisp/emacs-lisp/eieio.el b/lisp/emacs-lisp/eieio.el
index 38436d1f944..864ac2616b9 100644
--- a/lisp/emacs-lisp/eieio.el
+++ b/lisp/emacs-lisp/eieio.el
@@ -710,6 +710,9 @@ calls `initialize-instance' on that object."
;; Call the initialize method on the new object with the slots
;; that were passed down to us.
(initialize-instance new-object slots)
+ (when eieio-backward-compatibility
+ ;; Use symbol as type descriptor, for backwards compatibility.
+ (aset new-object 0 class))
;; Return the created object.
new-object))