
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.
24 lines
512 B
Racket
24 lines
512 B
Racket
#lang racket/base
|
|
|
|
(module u racket
|
|
(define (mixin cls)
|
|
(class cls
|
|
(super-new)
|
|
(define/public (n x) (add1 x))))
|
|
|
|
(provide mixin))
|
|
|
|
(module t typed/racket
|
|
;; expects a mixin that adds n
|
|
(require/typed (submod ".." u)
|
|
[mixin
|
|
(All (r #:row)
|
|
(-> (Class #:row-var r)
|
|
(Class #:row-var r [n (-> Integer Integer)])))])
|
|
|
|
(mixin (class object%
|
|
(super-new)
|
|
(define/public (m x) x))))
|
|
|
|
(require 't)
|