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,30 +222,30 @@
[candidates '()] ; from cases [candidates '()] ; from cases
[parts-acc '()]) ; from parts [parts-acc '()]) ; from parts
;; discard subsumed cases (supertype modulo filters) ;; keep only the domains for which the associated function type
;; is consistent with the expected type
(if (not (null? cases)) (if (not (null? cases))
(let ([head (car cases)] [tail (cdr cases)]) (if (returns-subtype-of-expected? (car cases))
(if (is-subsumed-in? head tail) (loop (cdr cases) (cdr parts)
(loop tail (cdr parts) (cons (car cases) candidates) ; we keep this one
candidates parts-acc) ; we discard this one (cons (car parts) parts-acc))
(loop tail (cdr parts) (loop (cdr cases) (cdr parts)
(cons head candidates) ; we keep this one candidates parts-acc)) ; we discard this one
(cons (car parts) parts-acc))))
;; keep only the domains for which the associated function type ;; discard subsumed cases (supertype modulo filters)
;; is consistent with the expected type
(let loop ([cases candidates] (let loop ([cases candidates]
[parts parts-acc] [parts parts-acc]
;; accumulators ;; accumulators
[candidates '()] [candidates '()]
[parts-acc '()]) [parts-acc '()])
(if (not (null? cases)) (if (not (null? cases))
(if (returns-subtype-of-expected? (car cases)) (let ([head (car cases)] [tail (cdr cases)])
(loop (cdr cases) (cdr parts) (if (is-subsumed-in? head tail)
(cons (car cases) candidates) ; we keep this one (loop tail (cdr parts)
(cons (car parts) parts-acc)) candidates parts-acc) ; we discard this one
(loop (cdr cases) (cdr parts) (loop tail (cdr parts)
candidates parts-acc)) ; we discard this one (cons head candidates) ; we keep this one
(cons (car parts) parts-acc))))
;; 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