Whitespace fixes, small optimizations of union cases.
This commit is contained in:
parent
43c0177895
commit
64a1aee65d
|
@ -356,9 +356,25 @@
|
||||||
(subtype* A0 other t*)
|
(subtype* A0 other t*)
|
||||||
(fail! s t)))]
|
(fail! s t)))]
|
||||||
;; for unions, we check the cross-product
|
;; for unions, we check the cross-product
|
||||||
[((Union: es) t) (or (and (andmap (lambda (elem) (subtype* A0 elem t)) es) A0)
|
;; some special cases for better performance
|
||||||
|
[((Union: (list e1 e2)) t)
|
||||||
|
(if (and (subtype* A0 e1 t) (subtype* A0 e2 t))
|
||||||
|
A0
|
||||||
(fail! s t))]
|
(fail! s t))]
|
||||||
[(s (Union: es)) (or (and (ormap (lambda (elem) (subtype*/no-fail A0 s elem)) es) A0)
|
[((Union: (list e1 e2 e3)) t)
|
||||||
|
(if (and (subtype* A0 e1 t) (subtype* A0 e2 t) (subtype* A0 e3 t))
|
||||||
|
A0
|
||||||
|
(fail! s t))]
|
||||||
|
[((Union: es) t)
|
||||||
|
(if (for/and ([elem (in-list es)])
|
||||||
|
(subtype* A0 elem t))
|
||||||
|
A0
|
||||||
|
(fail! s t))]
|
||||||
|
[(s (Union: es))
|
||||||
|
(if (for/or ([elem (in-list es)])
|
||||||
|
(with-handlers ([exn:subtype? (lambda _ #f)])
|
||||||
|
(subtype* A0 s elem)))
|
||||||
|
A0
|
||||||
(fail! s t))]
|
(fail! s t))]
|
||||||
;; subtyping on immutable structs is covariant
|
;; subtyping on immutable structs is covariant
|
||||||
[((Struct: nm _ flds proc _ _ _ _) (Struct: nm* _ flds* proc* _ _ _ _)) (=> nevermind)
|
[((Struct: nm _ flds proc _ _ _ _) (Struct: nm* _ flds* proc* _ _ _ _)) (=> nevermind)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user