* lisp/emacs-lisp/cl-generic.el: Try and fix bug#49866

(cl-generic-generalizers): Remember the specializers that match
a given value.
(cl--generic-eql-generalizer): Adjust accordingly.

* test/lisp/emacs-lisp/cl-generic-tests.el (cl-generic-test-01-eql):
Add corresponding test.
This commit is contained in:
Stefan Monnier
2021-08-09 19:03:01 -04:00
parent 0509f3921b
commit 75de09b9de
2 changed files with 21 additions and 13 deletions

View File

@@ -60,7 +60,10 @@
(defvar cl--generic-fooval 41)
(cl-defmethod cl--generic-1 ((_x (eql (+ cl--generic-fooval 1))) _y)
"forty-two")
(should (equal (cl--generic-1 42 nil) "forty-two")))
(cl-defmethod cl--generic-1 (_x (_y (eql 42)))
"FORTY-TWO")
(should (equal (cl--generic-1 42 nil) "forty-two"))
(should (equal (cl--generic-1 nil 42) "FORTY-TWO")))
(cl-defstruct cl-generic-struct-parent a b)
(cl-defstruct (cl-generic-struct-child1 (:include cl-generic-struct-parent)) c)