Generate channel contracts in TR

original commit: f2ddc66333512cfc7e24f2cb91de43464f5a59c1
This commit is contained in:
Asumu Takikawa 2013-11-19 12:01:22 -05:00
parent a6f0db1fdb
commit 9b08a80030
2 changed files with 21 additions and 0 deletions

View File

@ -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"))]))))

View File

@ -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")