Skip to content

Commit c403c91

Browse files
committed
[fix] make defpolymorph emit notes just once
1 parent dbcf744 commit c403c91

File tree

2 files changed

+40
-32
lines changed

2 files changed

+40
-32
lines changed

src/dispatch.lisp

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -167,31 +167,33 @@ If DOCUMENTATION is non-NIL, returns three values: DECLARATIONS and remaining BO
167167
(ftype-proclaimation
168168
static-dispatch-name effective-type-list return-type env)))
169169

170-
`(eval-when (:compile-toplevel :load-toplevel :execute)
171-
172-
(unless (and (fboundp ',name)
173-
(typep (function ,name) 'polymorphic-function))
174-
(define-polymorphic-function ,name ,untyped-lambda-list))
175-
176-
(setf (fdefinition ',static-dispatch-name) ,lambda-body)
177-
,ftype-proclaimation
178-
(register-polymorph ',name nil
179-
',doc
180-
',typed-lambda-list
181-
',type-list
182-
',effective-type-list
183-
nil
184-
nil
185-
',return-type
186-
nil
187-
',static-dispatch-name
188-
',lambda-list-type
189-
',(run-time-applicable-p-form parameters)
190-
nil
191-
#+sbcl (sb-c:source-location))
192-
,(when invalidate-pf
193-
`(invalidate-polymorphic-function-lambda (fdefinition ',name)))
194-
',name))))
170+
`(progn
171+
(eval-when (:compile-toplevel :load-toplevel :execute)
172+
173+
(unless (and (fboundp ',name)
174+
(typep (function ,name) 'polymorphic-function))
175+
(define-polymorphic-function ,name ,untyped-lambda-list)))
176+
(eval-when (:load-toplevel :execute)
177+
,ftype-proclaimation
178+
(setf (fdefinition ',static-dispatch-name) ,lambda-body))
179+
(eval-when (:compile-toplevel :load-toplevel :execute)
180+
(register-polymorph ',name nil
181+
',doc
182+
',typed-lambda-list
183+
',type-list
184+
',effective-type-list
185+
nil
186+
nil
187+
',return-type
188+
nil
189+
',static-dispatch-name
190+
',lambda-list-type
191+
',(run-time-applicable-p-form parameters)
192+
nil
193+
#+sbcl (sb-c:source-location))
194+
,(when invalidate-pf
195+
`(invalidate-polymorphic-function-lambda (fdefinition ',name)))
196+
',name)))))
195197

196198
;;; CLHS recommends that
197199
;;; Macros intended for use in top level forms should be written so that

src/nonlite/dispatch.lisp

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -220,18 +220,24 @@ in the lambda list; the consequences of mutation are undefined.
220220
;; NOTE: We need the LAMBDA-BODY due to compiler macros,
221221
;; and "objects of type FUNCTION can't be dumped into fasl files"
222222
`(progn
223+
223224
(eval-when (:compile-toplevel :load-toplevel :execute)
224225
(unless (and (fboundp ',name)
225226
(typep (function ,name) 'polymorphic-function))
226227
(define-polymorphic-function ,name ,untyped-lambda-list)))
228+
227229
#+sbcl ,sbcl-deftransform-form
228-
,(when inline-notes
229-
;; Even STYLE-WARNING isn't appropriate to this, because we want to
230-
;; inform the user of the warnings even when INLINE option is supplied.
231-
`(compiler-macro-notes:with-notes (',whole nil :unwind-on-signal nil)
232-
(signal 'defpolymorph-note :datum ,inline-notes)
233-
t))
230+
234231
(eval-when (:load-toplevel :execute)
232+
233+
,(when inline-notes
234+
;; Even STYLE-WARNING isn't appropriate to this, because we want to
235+
;; inform the user of the warnings even when INLINE option is supplied.
236+
`(compiler-macro-notes:with-notes
237+
(',whole nil :unwind-on-signal nil)
238+
(signal 'defpolymorph-note :datum ,inline-notes)
239+
t))
240+
235241
;; We have implemented inlining through the PF-COMPILER-MACRO.
236242
;; In addition to inlining, it also propagates the type declarations
237243
;; so that further compiler/macroexpansions can make use of this info.
@@ -247,8 +253,8 @@ in the lambda list; the consequences of mutation are undefined.
247253
`(with-muffled-compilation-warnings
248254
(setf (fdefinition ',static-dispatch-name) ,lambda-body))
249255
`(setf (fdefinition ',static-dispatch-name) ,lambda-body)))
250-
(eval-when (:compile-toplevel :load-toplevel :execute)
251256

257+
(eval-when (:compile-toplevel :load-toplevel :execute)
252258
(register-polymorph ',name ',inline
253259
',doc
254260
',typed-lambda-list

0 commit comments

Comments
 (0)