From 826a08d80c65d00dc0b77c89e4a6c2967bfef74c Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 20 Nov 2014 20:39:37 -0500 Subject: [PATCH] Put Instance types in the seen list for subtyping Since we resolve under Instance types for subtyping we need to put them in the current-seen list too. Fixes an infinite loop bug in subtyping. --- .../typed-racket/types/current-seen.rkt | 1 + .../typed-racket/unit-tests/class-tests.rkt | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/current-seen.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/current-seen.rkt index f44c56a3da..33baac42e2 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/current-seen.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/current-seen.rkt @@ -17,6 +17,7 @@ (define (remember s t A) (if (or (Mu? s) (Mu? t) (Name? s) (Name? t) + (Instance? s) (Instance? t) (Struct? s) (Struct? t) (App? s) (App? t)) (cons (seen-before s t) A) 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 3168e69ee5..1e6fb28608 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 @@ -1651,4 +1651,20 @@ (: d% D) (define d% (class object% (super-new) (define/public (m) (void)))) (send (new d%) m)) - Univ])) + Univ] + ;; Test for an infinite loop bug during subtyping for classes + [tc-e (let () + (define-type-alias A% (Class [get-this (-> (Instance A%))])) + (define-type-alias B% (Class [get-this (-> (Instance B%))])) + (: a% A%) + (define a% + (class object% + (super-new) + (define/public (get-this) this))) + (: b% B%) + (define b% + (class a% + (super-new) + (define/override (get-this) this))) + (void)) + -Void]))