typed-racket/typed-racket-test/succeed/sealing-contract-3.rkt
Asumu Takikawa 92d1dd1c5e Add sealing contracts for row polymorphic types
This enables contract generation in the negative
direction (untyped->typed) for row polymorphic types
(basically mixin types).

Depends on `class-seal` and `class-unseal` in
the racket/class library.
2015-05-13 20:52:32 -04:00

27 lines
574 B
Racket

#lang racket/base
(module u racket
(define state #f)
(define (mixin cls)
(class cls
(super-new)
(define/public (n x) x)))
(provide mixin))
(module t typed/racket
(require/typed (submod ".." u)
[mixin
(All (r #:row)
(-> (Class #:row-var r)
(Class #:row-var r [n (-> Integer Integer)])))])
;; ok to call mixin with different types
(mixin (class object% (super-new)))
(mixin (class object%
(super-new)
(define/public (m x) x))))
(require 't)