0.9.16.1:
authorChristophe Rhodes <csr21@cam.ac.uk>
Mon, 28 Aug 2006 12:08:19 +0000 (12:08 +0000)
committerChristophe Rhodes <csr21@cam.ac.uk>
Mon, 28 Aug 2006 12:08:19 +0000 (12:08 +0000)
Rework the named :complex-intersection-arg2 method for instance
and funcallable-instance, making it a lot clearer and fixing
bugs in the process...
... structure-classoids are always subtypep instance and never
intersect funcallable-instance;
... standard-classoids are different.  It's possible to make
a subclass of an instance class which is
funcallable-instance (if you pardon the loose
construction), while the reverse is not possible.

src/code/late-type.lisp
tests/type.impure.lisp
version.lisp-expr

index 1c5b8ea..2fb73b6 100644 (file)
   ;;(aver (not (eq type2 *wild-type*))) ; * isn't really a type.
   (cond
     ((eq type2 *instance-type*)
-     (if (classoid-p type1)
-         (if (and (not (member type1 *non-instance-classoid-types*
-                               :key #'find-classoid))
-                  (not (eq type1 (find-classoid 'function)))
-                  (not (find (classoid-layout (find-classoid 'function))
-                             (layout-inherits (classoid-layout type1)))))
-             (if (or (structure-classoid-p type1)
-                     (and (not (eq type1 (find-classoid 'stream)))
-                          (not (find (classoid-layout (find-classoid 'stream))
-                                     (layout-inherits (classoid-layout type1))))))
-                 type1
-                 nil)
-             *empty-type*)
-         (if (or (type-might-contain-other-types-p type1)
-                 (member-type-p type1))
-             nil
-             *empty-type*)))
+     (typecase type1
+       (structure-classoid type1)
+       (classoid
+        (if (and (not (member type1 *non-instance-classoid-types*
+                              :key #'find-classoid))
+                 (not (eq type1 (find-classoid 'function)))
+                 (not (find (classoid-layout (find-classoid 'function))
+                            (layout-inherits (classoid-layout type1)))))
+            nil
+            *empty-type*))
+       (t
+        (if (or (type-might-contain-other-types-p type1)
+                (member-type-p type1))
+            nil
+            *empty-type*))))
     ((eq type2 *funcallable-instance-type*)
-     (if (classoid-p type1)
-         (if (and (not (member type1 *non-instance-classoid-types*
-                               :key #'find-classoid))
-                  (find (classoid-layout (find-classoid 'function))
-                        (layout-inherits (classoid-layout type1))))
-             type1
-             (if (type= type1 (find-classoid 'function))
-                 type2
-                 nil))
-         (if (fun-type-p type1)
-             nil
-             (if (or (type-might-contain-other-types-p type1)
-                     (member-type-p type1))
-                 nil
-                 *empty-type*))))
+     (typecase type1
+       (structure-classoid *empty-type*)
+       (classoid
+        (if (and (not (member type1 *non-instance-classoid-types*
+                              :key #'find-classoid))
+                 (find (classoid-layout (find-classoid 'function))
+                       (layout-inherits (classoid-layout type1))))
+            type1
+            (if (type= type1 (find-classoid 'function))
+                type2
+                nil)))
+       (fun-type nil)
+       (t
+        (if (or (type-might-contain-other-types-p type1)
+                (member-type-p type1))
+            nil
+            *empty-type*))))
     (t (hierarchical-intersection2 type1 type2))))
 
 (!define-type-method (named :complex-union2) (type1 type2)
index e9891c9..caaefaf 100644 (file)
   (assert (not ok))
   (assert (not win)))
 
-;;; precice unions of array types (was bug 306a)
+;;; precise unions of array types (was bug 306a)
 (defun bug-306-a (x)
   (declare (optimize speed)
            (type (or (array cons) (array vector)) x))
   (elt (aref x 0) 0))
 (assert (= 0 (bug-306-a #((0)))))
-
+\f
+;;; FUNCALLABLE-INSTANCE is a subtype of function.
+(assert-t-t (subtypep '(and pathname function) nil))
+(assert-t-t (subtypep '(and pathname sb-kernel:funcallable-instance) nil))
+(assert (not (subtypep '(and stream function) nil)))
+(assert (not (subtypep '(and stream sb-kernel:funcallable-instance) nil)))
+(assert (not (subtypep '(and function standard-object) nil)))
+(assert (not (subtypep '(and sb-kernel:funcallable-instance standard-object) nil)))
+
+;;; also, intersections of classes with INSTANCE should not be too
+;;; general
+(assert (not (typep #'print-object '(and standard-object sb-kernel:instance))))
+(assert (not (subtypep 'standard-object '(and standard-object sb-kernel:instance))))
+\f
 ;;; success
index b57c5cb..b8cef80 100644 (file)
@@ -17,4 +17,4 @@
 ;;; checkins which aren't released. (And occasionally for internal
 ;;; versions, especially for internal versions off the main CVS
 ;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"0.9.16"
+"0.9.16.1"