Flip order of type simplification passes.

This commit is contained in:
Vincent St-Amour 2011-07-22 16:38:15 -04:00
parent 5b6d0ae167
commit 84931448b5

View File

@ -222,7 +222,22 @@
[candidates '()] ; from cases [candidates '()] ; from cases
[parts-acc '()]) ; from parts [parts-acc '()]) ; from parts
;; keep only the domains for which the associated function type
;; is consistent with the expected type
(if (not (null? cases))
(if (returns-subtype-of-expected? (car cases))
(loop (cdr cases) (cdr parts)
(cons (car cases) candidates) ; we keep this one
(cons (car parts) parts-acc))
(loop (cdr cases) (cdr parts)
candidates parts-acc)) ; we discard this one
;; discard subsumed cases (supertype modulo filters) ;; discard subsumed cases (supertype modulo filters)
(let loop ([cases candidates]
[parts parts-acc]
;; accumulators
[candidates '()]
[parts-acc '()])
(if (not (null? cases)) (if (not (null? cases))
(let ([head (car cases)] [tail (cdr cases)]) (let ([head (car cases)] [tail (cdr cases)])
(if (is-subsumed-in? head tail) (if (is-subsumed-in? head tail)
@ -232,21 +247,6 @@
(cons head candidates) ; we keep this one (cons head candidates) ; we keep this one
(cons (car parts) parts-acc)))) (cons (car parts) parts-acc))))
;; keep only the domains for which the associated function type
;; is consistent with the expected type
(let loop ([cases candidates]
[parts parts-acc]
;; accumulators
[candidates '()]
[parts-acc '()])
(if (not (null? cases))
(if (returns-subtype-of-expected? (car cases))
(loop (cdr cases) (cdr parts)
(cons (car cases) candidates) ; we keep this one
(cons (car parts) parts-acc))
(loop (cdr cases) (cdr parts)
candidates parts-acc)) ; we discard this one
;; among the domains that fit with the expected type, we only ;; among the domains that fit with the expected type, we only
;; need to keep the most liberal ;; need to keep the most liberal
;; since we only care about permissiveness of domains, we ;; since we only care about permissiveness of domains, we