(define-type … (Instance X)) breaks when X is a parametric type synonym, since Racket 8.7

Hi,

Suppose I have the following typed class:

(define my-class%
  (class object%
    #:forall (A)
    (super-new)
    (init-field [x : A])
    (define/public (get-x) x)))

I can define a synonym for the type of this class and then use it like so:

(define-type (MyClass% A) (Class (field (x A)) (get-x (-> A))))
(: a (Instance (MyClass% Boolean)))
(define a (new (inst my-class% Boolean) [x #t]))

I can also define a synonym for an instance of this class type, fully spelled out:

(define-type (MyClassInstance A) (Instance (Class (field (x A)) (get-x (-> A)))))

However, the following breaks, since Racket 8.7 I think:

(define-type (MyClassInstance A) (Instance (MyClass% A)))
; Type Checker: parse error in type;
;  expected a class type for argument to Instance
;   given: (MyClass% A)
;   in: (Instance (MyClass% A))

This used to work with Racket 8.6 as far as I remember (I had a long day-job blackout :smiley: )

Is this breakage intended or a bug?

This is a bug.
I will file a bug and take a look at it.

2 Likes