summaryrefslogtreecommitdiff
path: root/lisp/emacs-lisp/cl-generic.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2022-09-19 16:19:44 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2022-09-19 16:20:01 -0400
commitbd40ec5d57c0787530ebac1e14352a34fe235844 (patch)
tree02a9631e435ca8920039e7d21691b2415d9b581d /lisp/emacs-lisp/cl-generic.el
parent4b84f44015ca4d77500a22058be9e205343ad36d (diff)
downloademacs-bd40ec5d57c0787530ebac1e14352a34fe235844.tar.gz
emacs-bd40ec5d57c0787530ebac1e14352a34fe235844.tar.bz2
emacs-bd40ec5d57c0787530ebac1e14352a34fe235844.zip
* lisp/emacs-lisp/cl-generic.el (cl--generic-lambda): Fix bug#57903
Fall back to old slower calling convention in dynbound code (bug#56596).
Diffstat (limited to 'lisp/emacs-lisp/cl-generic.el')
-rw-r--r--lisp/emacs-lisp/cl-generic.el27
1 files changed, 21 insertions, 6 deletions
diff --git a/lisp/emacs-lisp/cl-generic.el b/lisp/emacs-lisp/cl-generic.el
index 0560ddda268..3fd85bcb880 100644
--- a/lisp/emacs-lisp/cl-generic.el
+++ b/lisp/emacs-lisp/cl-generic.el
@@ -425,11 +425,13 @@ the specializer used will be the one returned by BODY."
;; only called with explicit arguments.
(uses-cnm (macroexp--fgrep `((,cnm) (,nmp)) nbody))
(λ-lift (mapcar #'car uses-cnm)))
- (if (not uses-cnm)
- (cons nil
- `#'(lambda (,@args)
- ,@(car parsed-body)
- ,nbody))
+ (cond
+ ((not uses-cnm)
+ (cons nil
+ `#'(lambda (,@args)
+ ,@(car parsed-body)
+ ,nbody)))
+ (lexical-binding
(cons 'curried
`#'(lambda (,nm) ;Called when constructing the effective method.
(let ((,nmp (if (cl--generic-isnot-nnm-p ,nm)
@@ -465,7 +467,20 @@ the specializer used will be the one returned by BODY."
;; A destructuring-bind would do the trick
;; as well when/if it's more efficient.
(apply (lambda (,@λ-lift ,@args) ,nbody)
- ,@λ-lift ,arglist)))))))))
+ ,@λ-lift ,arglist)))))))
+ (t
+ (cons t
+ `#'(lambda (,cnm ,@args)
+ ,@(car parsed-body)
+ ,(macroexp-warn-and-return
+ "cl-defmethod used without lexical-binding"
+ (if (not (assq nmp uses-cnm))
+ nbody
+ `(let ((,nmp (lambda ()
+ (cl--generic-isnot-nnm-p ,cnm))))
+ ,nbody))
+ 'lexical t)))))
+ ))
(f (error "Unexpected macroexpansion result: %S" f))))))
(put 'cl-defmethod 'function-documentation