diff --git a/typed-racket-lib/typed-racket/typecheck/error-message.rkt b/typed-racket-lib/typed-racket/typecheck/error-message.rkt index 26755f18..c0fd1145 100644 --- a/typed-racket-lib/typed-racket/typecheck/error-message.rkt +++ b/typed-racket-lib/typed-racket/typecheck/error-message.rkt @@ -53,10 +53,8 @@ "type variables bound in different scopes")] [((? Class?) (? Class?)) (class-mismatch r1 r2)] - [((Instance: c1) (Instance: c2)) - (define r1 (resolve c1)) - (define r2 (resolve c2)) - (class-mismatch r1 r2 #t)] + [((Instance: (app resolve (? Class? c1))) (Instance: (app resolve (? Class? c2)))) + (class-mismatch c1 c2 #t)] ;; Don't call this with resolved types since we may want to print ;; the type alias name instead of the actual type [(_ _) (type-mismatch t1 t2)])) diff --git a/typed-racket-lib/typed-racket/types/printer.rkt b/typed-racket-lib/typed-racket/types/printer.rkt index 3a356ee3..c4cc10e7 100644 --- a/typed-racket-lib/typed-racket/types/printer.rkt +++ b/typed-racket-lib/typed-racket/types/printer.rkt @@ -498,6 +498,7 @@ [(Syntax: t) `(Syntaxof ,(t->s t))] [(Instance: (and (? has-name?) cls)) `(Instance ,(t->s cls))] [(Instance: (? Class? cls)) (class->sexp cls #:object? #t)] + [(Instance: t) `(Instance ,(t->s t))] ; for cases like Error [(ClassTop:) 'ClassTop] [(? Class?) (class->sexp type)] [(Result: t (or (NoFilter:) (FilterSet: (Top:) (Top:))) (or (NoObject:) (Empty:))) (type->sexp t)] diff --git a/typed-racket-test/unit-tests/class-tests.rkt b/typed-racket-test/unit-tests/class-tests.rkt index 378fc3b2..45d9b80f 100644 --- a/typed-racket-test/unit-tests/class-tests.rkt +++ b/typed-racket-test/unit-tests/class-tests.rkt @@ -1792,4 +1792,12 @@ (ann (class object% (super-new) (init-rest [rst : (Listof String)])) (Class (init-rest (Listof Void)))) (error "foo")) - #:msg #rx"expected: \\(Listof Void\\).*given: \\(Listof String\\)"])) + #:msg #rx"expected: \\(Listof Void\\).*given: \\(Listof String\\)"] + ;; PR 14942 + [tc-err (let () + (: x (Instance BadAlias)) + (define x (error "foo")) + (: y (Object (field [x Any]))) + (define y x) + (error "foo")) + #:msg "parse error in type"]))