(defsubst eieio--object-class-tag (obj)
(aref obj 0))
-(defsubst eieio--object-class (obj)
- (eieio--object-class-tag obj))
-
\f
;;; Important macros used internally in eieio.
(or (cl--find-class class) class)
class))
+(defsubst eieio--object-class (obj)
+ (let ((tag (eieio--object-class-tag obj)))
+ (if eieio-backward-compatibility
+ (eieio--class-object tag)
+ tag)))
+
(defun class-p (x)
"Return non-nil if X is a valid class vector.
X can also be is a symbol."
(defun eieio-object-p (obj)
"Return non-nil if OBJ is an EIEIO object."
(and (recordp obj)
- (eieio--class-p (eieio--object-class-tag obj))))
+ (eieio--class-p (eieio--object-class obj))))
(define-obsolete-function-alias 'object-p 'eieio-object-p "25.1")
;; 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))
:type vector
:initarg :random-vector)))
-(ert-deftest eieio-test-persist-hash-and-vector ()
+(defun eieio-test-persist-hash-and-vector ()
(let* ((jane (make-instance 'person :name "Jane"))
(bob (make-instance 'person :name "Bob"))
(hans (make-instance 'person :name "Hans"))
(aset (car (slot-value class 'janitors)) 1 hans)
(aset (nth 1 (slot-value class 'janitors)) 1 dierdre)
(unwind-protect
- ;; FIXME: This should not error.
- (should-error (persist-test-save-and-compare class))
+ (persist-test-save-and-compare class)
(delete-file (oref class file)))))
+(ert-deftest eieio-persist-hash-and-vector-backward-compatibility ()
+ (let ((eieio-backward-compatibility t)) ; The default.
+ (eieio-test-persist-hash-and-vector)))
+
+(ert-deftest eieio-persist-hash-and-vector-no-backward-compatibility ()
+ :expected-result :failed ;; Bug#29220.
+ (let ((eieio-backward-compatibility nil))
+ (eieio-test-persist-hash-and-vector)))
+
;; Extra quotation of lists inside other objects (Gnus registry), also
;; bug#29220.
:initarg :htab
:type hash-table)))
-(ert-deftest eieio-test-persist-interior-lists ()
+(defun eieio-test-persist-interior-lists ()
(let* ((thing (make-instance
'eieio-container
:vec [nil]
(setf (nth 2 (cadar alst)) john
(nth 2 (cadadr alst)) alexie)
(unwind-protect
- ;; FIXME: Should not error.
- (should-error (persist-test-save-and-compare thing))
+ (persist-test-save-and-compare thing)
(delete-file (slot-value thing 'file)))))
+(ert-deftest eieio-test-persist-interior-lists-backward-compatibility ()
+ (let ((eieio-backward-compatibility t)) ; The default.
+ (eieio-test-persist-interior-lists)))
+
+(ert-deftest eieio-test-persist-interior-lists-no-backward-compatibility ()
+ :expected-result :failed ;; Bug#29220.
+ (let ((eieio-backward-compatibility nil))
+ (eieio-test-persist-interior-lists)))
+
;;; eieio-test-persist.el ends here