1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-06 06:20:55 -08:00

(cl-generic-define-method): Try and fix bug#77464

* lisp/emacs-lisp/cl-generic.el (cl-generic-define-method): Don't set
the function to `dummy`, even temporarily.
This commit is contained in:
Stefan Monnier 2025-04-13 12:45:54 -04:00
parent 1dee377bad
commit 19913b1567

View file

@ -644,22 +644,24 @@ The set of acceptable TYPEs (also called \"specializers\") is defined
;; FIXME: Try to avoid re-constructing a new function if the old one
;; is still valid (e.g. still empty method cache)?
(gfun (cl--generic-make-function generic)))
(unless (symbol-function sym)
(defalias sym 'dummy)) ;Record definition into load-history.
(cl-pushnew `(cl-defmethod . ,(cl--generic-load-hist-format
(cl--generic-name generic)
qualifiers specializers))
current-load-list :test #'equal)
(let ((old-adv-cc (get-advertised-calling-convention
(symbol-function sym)))
;; Prevent `defalias' from recording this as the definition site of
;; the generic function.
current-load-list)
(symbol-function sym))))
(when (listp old-adv-cc)
(set-advertised-calling-convention gfun old-adv-cc nil))
;; But do use `defalias', so that it interacts properly with nadvice,
;; e.g. for tracing/debug-on-entry.
(defalias sym gfun)))))
(set-advertised-calling-convention gfun old-adv-cc nil)))
(if (not (symbol-function sym))
;; If this is the first definition, use it as "the definition site of
;; the generic function" since we don't know if a `cl-defgeneric'
;; will follow or not.
(defalias sym gfun)
;; Prevent `defalias' from recording this as the definition site of
;; the generic function. But do use `defalias', so it interacts
;; properly with nadvice, e.g. for ;; tracing/debug-on-entry.
(let (current-load-list)
(defalias sym gfun))))))
(defvar cl--generic-dispatchers (make-hash-table :test #'equal))