Skip to content
Browse files

Only test slot types when slot is `BOUNDP`.

  • Loading branch information...
1 parent c173e51 commit da07733a90b78a41b65b6ea4f091c75f69656a22 @sellout committed Mar 23, 2012
Showing with 9 additions and 2 deletions.
  1. +6 −0 quid-pro-quo-test.lisp
  2. +3 −2 src/metaclass.lisp
View
6 quid-pro-quo-test.lisp
@@ -315,6 +315,12 @@
(numberp (slot-value instance 'slot1)))
"yet another invariant"))
+(defclass feature-test-2 (feature-test)
+ ((slot2 :accessor slot2 :initarg :slot2 :type integer)))
+
+(test should-pass-type-invariant-when-slot-is-unbound
+ (is (= 0 (slot1 (make-instance 'feature-test-2)))))
+
(defgeneric test-qpq-/ (arg1 arg2)
(:method-combination contract :invariant-check nil)
(:method :require "first arg isn't zero" ((m feature-test) (n feature-test))
View
5 src/metaclass.lisp
@@ -106,8 +106,9 @@
(defun passes-slot-type-invariants-p (object)
(loop for slot in (class-slots (class-of object))
- unless (typep (slot-value object (slot-definition-name slot))
- (slot-definition-type slot))
+ unless (implies (slot-boundp object (slot-definition-name slot))
+ (typep (slot-value object (slot-definition-name slot))
+ (slot-definition-type slot)))
return nil
finally (return t)))

0 comments on commit da07733

Please sign in to comment.
Something went wrong with that request. Please try again.