From efb877dbfbc168b4a34cfa085eeb8eab04ad32d5 Mon Sep 17 00:00:00 2001 From: AlexKnauth Date: Sat, 15 Aug 2015 14:36:45 -0500 Subject: [PATCH] fix inference with define-new-subtype --- typed-racket-lib/typed-racket/infer/infer-unit.rkt | 7 +++++++ typed-racket-test/succeed/define-new-subtype-infer.rkt | 8 ++++++++ 2 files changed, 15 insertions(+) create mode 100644 typed-racket-test/succeed/define-new-subtype-infer.rkt diff --git a/typed-racket-lib/typed-racket/infer/infer-unit.rkt b/typed-racket-lib/typed-racket/infer/infer-unit.rkt index f841725b..3120a5b4 100644 --- a/typed-racket-lib/typed-racket/infer/infer-unit.rkt +++ b/typed-racket-lib/typed-racket/infer/infer-unit.rkt @@ -540,6 +540,13 @@ #:when v) v))] + ;; from define-new-subtype + [((Distinction: nm1 id1 S) (app resolve (Distinction: nm2 id2 T))) + #:when (and (equal? nm1 nm2) (equal? id1 id2)) + (cg S T)] + [((Distinction: _ _ S) T) + (cg S T)] + ;; two structs with the same name ;; just check pairwise on the fields [((Struct: nm _ flds proc _ _) (Struct: nm* _ flds* proc* _ _)) diff --git a/typed-racket-test/succeed/define-new-subtype-infer.rkt b/typed-racket-test/succeed/define-new-subtype-infer.rkt new file mode 100644 index 00000000..e6f09834 --- /dev/null +++ b/typed-racket-test/succeed/define-new-subtype-infer.rkt @@ -0,0 +1,8 @@ +#lang typed/racket + +(define-new-subtype T (make-T (List Integer))) + +(: f : T -> Integer) +(define (f t) + (define x (car t)) + (* x 2))