[racket] Typed classes: how to send to a value with union type
I'm making a snip in Typed Racket. I have essentially this:
(define admin (send this get-admin))
(define editor (and admin (send admin get-editor)))
(when editor
(send editor set-caret-owner #f))
I get this error:
Type Checker: send: type mismatch
expected: an object
given: (U (Instance Text%) (Instance Pasteboard%)) in:
(send editor set-caret-owner #f)
It's unexpected in the first place because text% and pasteboard% both
implement editor<%>. Guarding with (is-a? editor text%) doesn't work.
Casting doesn't work because TR can't generate a contract. How do I do this?
Neil ⊥