diff --git a/typed-racket-lib/typed-racket/private/type-contract.rkt b/typed-racket-lib/typed-racket/private/type-contract.rkt index 99a52485..a8f91801 100644 --- a/typed-racket-lib/typed-racket/private/type-contract.rkt +++ b/typed-racket-lib/typed-racket/private/type-contract.rkt @@ -402,6 +402,8 @@ (t->sc/poly type fail typed-side recursive-values t->sc)] [(? PolyDots?) (t->sc/polydots type fail typed-side recursive-values t->sc)] + [(? PolyRow?) + (t->sc/polyrow type fail typed-side recursive-values t->sc)] [(Mu: n b) (match-define (and n*s (list untyped-n* typed-n* both-n*)) (generate-temporaries (list n n n))) @@ -602,6 +604,8 @@ (t->sc/poly type fail typed-side recursive-values rec)] [(? PolyDots?) (t->sc/polydots type fail typed-side recursive-values rec)] + [(? PolyRow?) + (t->sc/polyrow type fail typed-side recursive-values rec)] [(? Function?) (t->sc/function type fail typed-side recursive-values loop #t)] [_ (fail #:reason "invalid method type")])) @@ -645,6 +649,16 @@ ;; in negative position, cannot generate for polydots yet (fail #:reason "cannot generate contract for variable arity polymorphic type"))) +;; Generate a contract for a row-polymorphic function type +(define (t->sc/polyrow type fail typed-side recursive-values t->sc) + (match-define (PolyRow: vs constraints body) type) + (if (not (from-untyped? typed-side)) + (let ((recursive-values (for/fold ([rv recursive-values]) ([v vs]) + (hash-set rv v (same any/sc))))) + (t->sc body #:recursive-values recursive-values)) + ;; FIXME: needs sealing contracts, disabled for now + (fail #:reason "cannot generate contract for row polymorphic type"))) + ;; Predicate that checks for an App type with a recursive ;; Name type in application position (define (has-name-app? type) diff --git a/typed-racket-test/unit-tests/contract-tests.rkt b/typed-racket-test/unit-tests/contract-tests.rkt index 1963caf7..e50d8405 100644 --- a/typed-racket-test/unit-tests/contract-tests.rkt +++ b/typed-racket-test/unit-tests/contract-tests.rkt @@ -144,6 +144,10 @@ (t (-polydots (a) -Symbol)) (t (-polydots (a) (->... (list) (a a) -Symbol))) + (t (-polyrow (a) (list null null null null) -Symbol)) + (t (-polyrow (a) (list null null null null) + (-> (-class #:row (-v a)) (-class #:row (-v a))))) + (t (-mu x (-Syntax x))) (t (-> (-> Univ -Bottom : -bot-filter) -Bottom : -bot-filter)) (t (-poly (A B) (-> A B (Un A B)))) @@ -217,6 +221,8 @@ #f)) (t (-class #:method ([m (-poly (x) (-> x x))]))) (t (-class #:method ([m (-polydots (x) (->... (list) (x x) -Void))]))) + (t (-class #:method ([m (-polyrow (x) (list null null null null) + (-> (-class #:row (-v x)) -Void))]))) ;; typed/untyped interaction tests (t-int (-poly (a) (-> a a))