diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt index db98767e..957053d2 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt @@ -161,6 +161,8 @@ (match (and expected (resolve expected)) [(tc-result1: (and self-class-type (Class: _ _ _ _ _))) (do-check form #t self-class-type)] + [(tc-result1: (Poly-names: ns body-type)) + (check-class form (ret body-type))] [#f (do-check form #f #f)] [_ (check-below (do-check form #f #f) expected)])) diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/class-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/class-tests.rkt index b5e5a3fa..43b76a23 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/class-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/class-tests.rkt @@ -973,5 +973,23 @@ (class: object% (super-new) (: x Integer) - (init-field x)))))) + (init-field x)))) + + ;; test polymorphic class + (check-ok + (: c% (All (A) (Class (init-field [x A])))) + (define c% + (class: object% + (super-new) + (init-field x))) + (new (inst c% Integer) [x 0])) + + ;; fails due to ill-typed polymorphic class body + (check-err #:exn #rx"Expected A, but got Positive-Byte" + (: c% (All (A) (Class (init-field [x A])))) + (define c% + (class: object% + (super-new) + (init-field x) + (set! x 5))))))