typed-racket/typed-racket-test/fail/opaque-object-contract-2.rkt
Asumu Takikawa 8d0c352dcc Add a custom object contract for use in TR
This corresponds to the more strict object contracts
from the OOPSLA paper. Also use `object/c-opaque` in
TR contract generation
2015-03-04 16:26:35 -05:00

23 lines
472 B
Racket

#;
(exn-pred #rx"cannot read or write.*blaming:.*b\\)")
#lang racket/base
;; Ensure that opaque object contracts prevent access to fields
;; that should be hidden from untyped code
(require racket/class)
(module a typed/racket
(provide o)
(: o (Object))
(define o (new (class object%
(super-new)
(field [x 0])))))
(module b racket
(require (submod ".." a))
(set-field! x o "wrong type")
(get-field x o))
(require 'b)