diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-contract.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-contract.rkt index 9b300739..3d82c557 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-contract.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/private/type-contract.rkt @@ -487,6 +487,9 @@ [(Hashtable: k v) (when (equal? kind flat-sym) (exit (fail))) #`(hash/c #,(t->c k #:kind chaperone-sym) #,(t->c v) #:immutable 'dont-care)] + [(Channel: t) + (set-chaperone!) + #`(channel/c #,(t->c/both t))] [else (exit (fail #:reason "contract generation not supported for this type"))])))) diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/fail/channel-contract.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/fail/channel-contract.rkt new file mode 100644 index 00000000..4c8c8a98 --- /dev/null +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/fail/channel-contract.rkt @@ -0,0 +1,18 @@ +#; +(exn-pred #rx"expected: Integer.*blaming: top-level") +#lang racket/load + +;; Test typed-untyped interaction with channels + +(module typed typed/racket + (: ch (Channelof (Boxof Integer))) + (define ch (make-channel)) + (: putter (-> Thread)) + (define (putter) + (thread (λ () (channel-put ch (box 3))))) + (provide putter ch)) + +(require 'typed) +(putter) +(set-box! (channel-get ch) "not an integer") +