EIEIO: Fix regession (bug#69631)

Not sure why earlier tests did not catch it, but there are more
places where we bump into problems because `eieio--class-precedence-list`
now returns also non-EIEIO classes.

* lisp/obsolete/eieio-compat.el
(eieio--generic-static-object-generalizer):
* lisp/emacs-lisp/eieio-core.el (eieio--generic-generalizer)
(eieio--generic-subclass-specializers): Handle non-EIEIO parents.

* test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el
(eieio-test-method-order-list-7): Adjust test.
This commit is contained in:
Stefan Monnier 2024-03-08 11:24:18 -05:00
parent 055e31f1d0
commit 5beb56fb53
3 changed files with 7 additions and 10 deletions

View file

@ -1056,8 +1056,7 @@ method invocation orders of the involved classes."
(lambda (tag &rest _)
(let ((class (cl--find-class tag)))
(and (eieio--class-p class)
(mapcar #'eieio--class-name
(eieio--class-precedence-list class))))))
(cl--class-allparents class)))))
(cl-defmethod cl-generic-generalizers :extra "class" (specializer)
"Support for dispatch on types defined by EIEIO's `defclass'."
@ -1079,10 +1078,9 @@ method invocation orders of the involved classes."
;; Instead, we add a new "subclass" specializer.
(defun eieio--generic-subclass-specializers (tag &rest _)
(when (eieio--class-p tag)
(mapcar (lambda (class)
`(subclass ,(eieio--class-name class)))
(eieio--class-precedence-list tag))))
(when (cl--class-p tag)
(mapcar (lambda (class) `(subclass ,class))
(cl--class-allparents tag))))
(cl-generic-define-generalizer eieio--generic-subclass-generalizer
60 (lambda (name &rest _) `(and (symbolp ,name) (cl--find-class ,name)))

View file

@ -150,10 +150,9 @@ Summary:
(lambda (tag &rest _)
(and (symbolp tag) (setq tag (cl--find-class tag))
(eieio--class-p tag)
(let ((superclasses (eieio--class-precedence-list tag))
(let ((superclasses (cl--class-allparents tag))
(specializers ()))
(dolist (superclass superclasses)
(setq superclass (eieio--class-name superclass))
(push superclass specializers)
(push `(eieio--static ,superclass) specializers))
(nreverse specializers)))))
@ -240,7 +239,7 @@ Summary:
(declare (obsolete cl-no-applicable-method "25.1"))
(apply #'cl-no-applicable-method method object args))
(define-obsolete-function-alias 'call-next-method 'cl-call-next-method "25.1")
(define-obsolete-function-alias 'call-next-method #'cl-call-next-method "25.1")
(defun next-method-p ()
(declare (obsolete cl-next-method-p "25.1"))
;; EIEIO's `next-method-p' just returned nil when called in an

View file

@ -259,7 +259,7 @@
(ans '(
(:PRIMARY D)
(:PRIMARY D-base1)
;; (:PRIMARY D-base2)
(:PRIMARY D-base2)
(:PRIMARY D-base0)
)))
(eitest-F (D nil))