diff --git a/collects/typed-scheme/private/free-variance.ss b/collects/typed-scheme/private/free-variance.ss index 006f8a1ad8..2562dcb404 100644 --- a/collects/typed-scheme/private/free-variance.ss +++ b/collects/typed-scheme/private/free-variance.ss @@ -63,7 +63,8 @@ (define (fix-bound vs bound) (define vs* (hash-map* (lambda (k v) v) vs)) (hash-remove! vs* bound) - (hash-set! vs* bound (cons bound Dotted))) + (hash-set! vs* bound (cons bound Dotted)) + vs*) ;; frees -> frees (define (flip-variances vs) diff --git a/collects/typed-scheme/private/subtype.ss b/collects/typed-scheme/private/subtype.ss index 5f7e3595be..04f3c89bd6 100644 --- a/collects/typed-scheme/private/subtype.ss +++ b/collects/typed-scheme/private/subtype.ss @@ -1,6 +1,6 @@ #lang scheme/base -(require "type-rep.ss" "unify.ss" "type-utils.ss" +(require (except-in "type-rep.ss" sub-eff) "unify.ss" "type-utils.ss" "tc-utils.ss" "effect-rep.ss" "type-comparison.ss" diff --git a/collects/typed-scheme/private/type-effect-convenience.ss b/collects/typed-scheme/private/type-effect-convenience.ss index 22317db1ae..73c11ef91b 100644 --- a/collects/typed-scheme/private/type-effect-convenience.ss +++ b/collects/typed-scheme/private/type-effect-convenience.ss @@ -69,7 +69,11 @@ (define make-arr* (case-lambda [(dom rng) (make-arr* dom rng #f (list) (list))] [(dom rng rest) (make-arr dom rng rest #f (list) (list))] - [(dom rng rest eff1 eff2) (make-arr dom rng rest #f eff1 eff2)])) + [(dom rng rest eff1 eff2) (make-arr dom rng rest #f eff1 eff2)] + [(dom rng rest drest eff1 eff2) (make-arr dom rng rest drest eff1 eff2)])) + +(define (make-arr-dots dom rng dty dbound) + (make-arr* dom rng #f (cons dty dbound) null null)) (define (make-promise-ty t) (make-Struct (string->uninterned-symbol "Promise") #f (list t) #f #f #'promise? values)) diff --git a/collects/typed-scheme/private/type-rep.ss b/collects/typed-scheme/private/type-rep.ss index dd2cdabd4c..ce8583d49e 100644 --- a/collects/typed-scheme/private/type-rep.ss +++ b/collects/typed-scheme/private/type-rep.ss @@ -103,8 +103,8 @@ (match drest [(cons t (? symbol? bnd)) (let ([vs (free-vars* t)]) - (flip-variances (fix-bound vs bnd)))] - [(cons t bnd) (flip-variances (free-vars* t))] + (list (flip-variances (fix-bound vs bnd))))] + [(cons t bnd) (list (flip-variances (free-vars* t)))] [_ null]) (list (free-vars* rng)) (map make-invariant @@ -113,8 +113,8 @@ (match drest [(cons t (? number? bnd)) (let ([vs (free-idxs* t)]) - (flip-variances (fix-bound vs bnd)))] - [(cons t bnd) (flip-variances (free-idxs* t))] + (list (flip-variances (fix-bound vs bnd))))] + [(cons t bnd) (list (flip-variances (free-idxs* t)))] [_ null]) (list (free-idxs* rng)) (map make-invariant @@ -520,6 +520,7 @@ free-vars* type-equal? type-compare type Type +(define (substitute-dots images name target) + (define (sb t) (substitute-dots images name t)) + (if (hash-ref (free-vars* target) name #f) + (type-case sb target + [#:F name* (if (eq? name* name) + (int-err "substitute-dots: got single variable ~a" name*) + target)] + [#:arr dom rng rest drest thn-eff els-eff + (if (and (pair? drest) + (eq? name (cdr drest))) + (make-arr (append + (map sb dom) + (map (lambda (img) (substitute img name (car drest))) images)) + (sb rng) + #f + #f + (map (lambda (e) (sub-eff sb e)) thn-eff) + (map (lambda (e) (sub-eff sb e)) els-eff)) + (make-arr (map sb dom) + (sb rng) + (and rest (sb rest)) + (and drest (cons (sb (car drest)) (cdr drest))) + (map (lambda (e) (sub-eff sb e)) thn-eff) + (map (lambda (e) (sub-eff sb e)) els-eff)))]) target)) ;; substitute many variables diff --git a/collects/typed-scheme/private/utils.ss b/collects/typed-scheme/private/utils.ss index 1d3275c9a7..efdc4da4d1 100644 --- a/collects/typed-scheme/private/utils.ss +++ b/collects/typed-scheme/private/utils.ss @@ -99,7 +99,7 @@ [(_ val) #'(? (lambda (x) (equal? val x)))]))) -(define-for-syntax printing? #t) +(define-for-syntax printing? #f) (define print-type* (box (lambda _ (error "print-type* not yet defined")))) (define print-effect* (box (lambda _ (error "print-effect* not yet defined"))))