Skip to content
This repository has been archived by the owner on Dec 29, 2018. It is now read-only.

Commit

Permalink
Merge pull request #99 from scymtym/fix-finalize-inheritance
Browse files Browse the repository at this point in the history
If necessary, call FINALIZE-INHERITANCE when parsing CLASS patterns
  • Loading branch information
Tomohiro Matsuyama committed Aug 16, 2014
2 parents 5cd8999 + 4e7a0a4 commit 961211a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
23 changes: 13 additions & 10 deletions src/pattern.lisp
Expand Up @@ -471,16 +471,19 @@ Examples:
;; we also resolve the slot names via MOP. If no slot found or too
;; many slots found, we will raise an error.
(when (keywordp (first slot-specs))
(setq slot-specs
(loop with class = (find-class class-name nil)
with all-slot-names = (mapcar #'closer-mop:slot-definition-name
(closer-mop:class-slots class))
for (slot-name . pattern) in (plist-alist slot-specs)
for slot-names = (remove-if (lambda (name) (string/= slot-name name)) all-slot-names)
collect (case (length slot-names)
(0 (error "Slot ~S not found" slot-name))
(1 `(,(first slot-names) ,pattern))
(t (error "Ambiguous slot name ~S" slot-name))))))
(let ((class (find-class class-name nil)))
(unless (closer-mop:class-finalized-p class)
(closer-mop:finalize-inheritance class))
(setq slot-specs
(loop with all-slot-names = (mapcar #'closer-mop:slot-definition-name
(closer-mop:class-slots class))
for (slot-name . pattern) in (plist-alist slot-specs)
for slot-names = (remove-if (lambda (name) (string/= slot-name name))
all-slot-names)
collect (case (length slot-names)
(0 (error "Slot ~S not found" slot-name))
(1 `(,(first slot-names) ,pattern))
(t (error "Ambiguous slot name ~S" slot-name)))))))
(apply #'make-class-pattern class-name
(loop for slot-spec in slot-specs
do (setq slot-spec (ensure-list slot-spec))
Expand Down
1 change: 0 additions & 1 deletion test/suite.lisp
Expand Up @@ -90,7 +90,6 @@
(defclass person ()
((name :initarg :name)
(age :initarg :age)))
(closer-mop:finalize-inheritance (find-class 'person))

(defstruct (point (:predicate point-p))
x y))
Expand Down

0 comments on commit 961211a

Please sign in to comment.