Skip to content

Commit

Permalink
Fix export to only export symbols of current package.
Browse files Browse the repository at this point in the history
Previously, defclass-star* would fail when overriding a slot of a superclass.
Example recipe:

    (setf hu.dwim.defclass-star::*export-slot-names-p* t)
    (hu.dwim.defclass-star:defclass* foo ()
        ((foo-name :initform "foo name")))

    (defpackage foo-package
      (:use :cl))
    (in-package foo-package)

    (hu.dwim.defclass-star:defclass* bar (cl-user:foo)
        ((cl-user:foo-name :initform "bar name")))
  • Loading branch information
Ambrevar authored and attila-lendvai committed Jan 29, 2021
1 parent 03e96b5 commit 39d458f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions source/defclass-star.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,14 @@ Use the slot name directly:
`(progn
,result
(eval-when (:compile-toplevel :load-toplevel :execute)
(export '(,@(append (when *export-class-name-p*
(list name))
*symbols-to-export*))
;; Don't try to export symbols that don't belong to *package*.
;; This can happen when inheriting from a class and
;; overriding some slot.
(export '(,@(remove-if (lambda (sym)
(not (eq (symbol-package sym) *package*)))
(append (when *export-class-name-p*
(list name))
*symbols-to-export*)))
,(package-name *package*)))
(find-class ',name nil))
result))))))
Expand Down

0 comments on commit 39d458f

Please # to comment.