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 f76a08acdc..155ec6562f 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 @@ -329,9 +329,12 @@ (values super-row super-inits super-fields super-methods super-augments super-init-rest)] [(tc-result1: t) - (tc-error/expr "expected a superclass but got value of type ~a" t - #:stx (hash-ref parse-info 'superclass-expr)) - (values #f null null null null)])) + (tc-error/expr/fields "type mismatch" + #:more "superclass expression should produce a class" + #:stx (hash-ref parse-info 'superclass-expr) + "expected" "a class" + "given" t) + (values #f null null null null #f)])) (define super-init-names (dict-keys super-inits)) (define super-field-names (dict-keys super-fields)) (define super-method-names (dict-keys super-methods)) 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 7fc4b33af6..4e23fdce45 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 @@ -45,7 +45,7 @@ (init x) (define/public (m x) 0))) (void)) - #:msg #rx"expected a superclass but"] + #:msg #rx"superclass expression should produce a class"] ;; Method using argument type [tc-e (let () (: e% (Class (init [x Integer]) @@ -173,6 +173,9 @@ (define n% (class j% (super-new))) (void)) -Void] + ;; fail, superclass expression is not a class with no expected type + [tc-err (class "foo" (super-new)) + #:msg "expected: a class"] ;; should fail, too many methods [tc-err (let () (: o% (Class))