Generate channel contracts in TR

This commit is contained in:
Asumu Takikawa 2013-11-19 12:01:22 -05:00
parent b563f0c876
commit f2ddc66333
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")