typed-racket/typed-racket-test/succeed/pr267-variation-0.rkt
Ben Greenman 3e2d020a19 Implement object/c-opaque-stronger
An opaque object contract is stronger than another (opaque) object contract if:
- it has stronger field/method contracts on fields/methods common to both
- and it has no more field/method contracts than the other, if the other is opaque
2017-01-06 02:41:59 -05:00

27 lines
713 B
Racket

#lang racket
;; Regression test for PR 267
;; https://github.com/racket/typed-racket/pull/267
;; Issue reported separately as:
;; https://github.com/racket/racket/issues/1198
;; becuase it was really a racket/contract issue
;; (impersonate-vector contracts were using chaperone-contract)
(define con
(object/c (field [a* any/c])
(regenerate (->m (object/c (field [a* (vectorof (object/c))]))))))
(define population%
(class object%
(super-new)
(init-field a*)
(define/public (regenerate)
(vector-ref (get-field a* this) 0)
this)))
(define pop
(contract con (new population% [a* (vector (new (class object% (super-new))))]) 'p 'n))
(void (send (send pop regenerate) regenerate))