diff options
| author | Stefan Monnier | 2024-03-08 11:24:18 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2024-03-08 11:24:18 -0500 |
| commit | 5beb56fb53b2d6ee9d5ad621b7fc2c9d1d0ec9c5 (patch) | |
| tree | 6e45fb5f16669828fad9ec50212fe5d4db4cf661 | |
| parent | 055e31f1d021ef2c8ac5cca505b5f73118736cff (diff) | |
| download | emacs-5beb56fb53b2d6ee9d5ad621b7fc2c9d1d0ec9c5.tar.gz emacs-5beb56fb53b2d6ee9d5ad621b7fc2c9d1d0ec9c5.zip | |
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.
| -rw-r--r-- | lisp/emacs-lisp/eieio-core.el | 10 | ||||
| -rw-r--r-- | lisp/obsolete/eieio-compat.el | 5 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el | 2 |
3 files changed, 7 insertions, 10 deletions
diff --git a/lisp/emacs-lisp/eieio-core.el b/lisp/emacs-lisp/eieio-core.el index 7af6e9ff1bb..9a73e7c7441 100644 --- a/lisp/emacs-lisp/eieio-core.el +++ b/lisp/emacs-lisp/eieio-core.el | |||
| @@ -1056,8 +1056,7 @@ method invocation orders of the involved classes." | |||
| 1056 | (lambda (tag &rest _) | 1056 | (lambda (tag &rest _) |
| 1057 | (let ((class (cl--find-class tag))) | 1057 | (let ((class (cl--find-class tag))) |
| 1058 | (and (eieio--class-p class) | 1058 | (and (eieio--class-p class) |
| 1059 | (mapcar #'eieio--class-name | 1059 | (cl--class-allparents class))))) |
| 1060 | (eieio--class-precedence-list class)))))) | ||
| 1061 | 1060 | ||
| 1062 | (cl-defmethod cl-generic-generalizers :extra "class" (specializer) | 1061 | (cl-defmethod cl-generic-generalizers :extra "class" (specializer) |
| 1063 | "Support for dispatch on types defined by EIEIO's `defclass'." | 1062 | "Support for dispatch on types defined by EIEIO's `defclass'." |
| @@ -1079,10 +1078,9 @@ method invocation orders of the involved classes." | |||
| 1079 | ;; Instead, we add a new "subclass" specializer. | 1078 | ;; Instead, we add a new "subclass" specializer. |
| 1080 | 1079 | ||
| 1081 | (defun eieio--generic-subclass-specializers (tag &rest _) | 1080 | (defun eieio--generic-subclass-specializers (tag &rest _) |
| 1082 | (when (eieio--class-p tag) | 1081 | (when (cl--class-p tag) |
| 1083 | (mapcar (lambda (class) | 1082 | (mapcar (lambda (class) `(subclass ,class)) |
| 1084 | `(subclass ,(eieio--class-name class))) | 1083 | (cl--class-allparents tag)))) |
| 1085 | (eieio--class-precedence-list tag)))) | ||
| 1086 | 1084 | ||
| 1087 | (cl-generic-define-generalizer eieio--generic-subclass-generalizer | 1085 | (cl-generic-define-generalizer eieio--generic-subclass-generalizer |
| 1088 | 60 (lambda (name &rest _) `(and (symbolp ,name) (cl--find-class ,name))) | 1086 | 60 (lambda (name &rest _) `(and (symbolp ,name) (cl--find-class ,name))) |
diff --git a/lisp/obsolete/eieio-compat.el b/lisp/obsolete/eieio-compat.el index 26648a4d7bb..8fdcebbd1c4 100644 --- a/lisp/obsolete/eieio-compat.el +++ b/lisp/obsolete/eieio-compat.el | |||
| @@ -150,10 +150,9 @@ Summary: | |||
| 150 | (lambda (tag &rest _) | 150 | (lambda (tag &rest _) |
| 151 | (and (symbolp tag) (setq tag (cl--find-class tag)) | 151 | (and (symbolp tag) (setq tag (cl--find-class tag)) |
| 152 | (eieio--class-p tag) | 152 | (eieio--class-p tag) |
| 153 | (let ((superclasses (eieio--class-precedence-list tag)) | 153 | (let ((superclasses (cl--class-allparents tag)) |
| 154 | (specializers ())) | 154 | (specializers ())) |
| 155 | (dolist (superclass superclasses) | 155 | (dolist (superclass superclasses) |
| 156 | (setq superclass (eieio--class-name superclass)) | ||
| 157 | (push superclass specializers) | 156 | (push superclass specializers) |
| 158 | (push `(eieio--static ,superclass) specializers)) | 157 | (push `(eieio--static ,superclass) specializers)) |
| 159 | (nreverse specializers))))) | 158 | (nreverse specializers))))) |
| @@ -240,7 +239,7 @@ Summary: | |||
| 240 | (declare (obsolete cl-no-applicable-method "25.1")) | 239 | (declare (obsolete cl-no-applicable-method "25.1")) |
| 241 | (apply #'cl-no-applicable-method method object args)) | 240 | (apply #'cl-no-applicable-method method object args)) |
| 242 | 241 | ||
| 243 | (define-obsolete-function-alias 'call-next-method 'cl-call-next-method "25.1") | 242 | (define-obsolete-function-alias 'call-next-method #'cl-call-next-method "25.1") |
| 244 | (defun next-method-p () | 243 | (defun next-method-p () |
| 245 | (declare (obsolete cl-next-method-p "25.1")) | 244 | (declare (obsolete cl-next-method-p "25.1")) |
| 246 | ;; EIEIO's `next-method-p' just returned nil when called in an | 245 | ;; EIEIO's `next-method-p' just returned nil when called in an |
diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el b/test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el index b244a56779a..fb2c6ea3b68 100644 --- a/test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el +++ b/test/lisp/emacs-lisp/eieio-tests/eieio-test-methodinvoke.el | |||
| @@ -259,7 +259,7 @@ | |||
| 259 | (ans '( | 259 | (ans '( |
| 260 | (:PRIMARY D) | 260 | (:PRIMARY D) |
| 261 | (:PRIMARY D-base1) | 261 | (:PRIMARY D-base1) |
| 262 | ;; (:PRIMARY D-base2) | 262 | (:PRIMARY D-base2) |
| 263 | (:PRIMARY D-base0) | 263 | (:PRIMARY D-base0) |
| 264 | ))) | 264 | ))) |
| 265 | (eitest-F (D nil)) | 265 | (eitest-F (D nil)) |