From 3c2e2546939f04036cb971567ec979f57ed015ca Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Fri, 14 Mar 2014 18:54:50 -0700 Subject: [PATCH] Fix implied-atomic to work on -top and -bot. original commit: 9e2787c0cf6eb3e45256ad31075978d3955ef34c --- .../typed-racket/types/filter-ops.rkt | 29 ++++++++++--------- .../typed-racket/unit-tests/filter-tests.rkt | 6 ++++ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/filter-ops.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/filter-ops.rkt index ed4a9e03..3225fba5 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/filter-ops.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/types/filter-ops.rkt @@ -36,20 +36,21 @@ ;; is f1 implied by f2? (define (implied-atomic? f1 f2) - (if (filter-equal? f1 f2) - #t - (match* (f1 f2) - [((OrFilter: fs) f2) - (memf (lambda (f) (filter-equal? f f2)) fs)] - [((TypeFilter: t1 p1 i1) - (TypeFilter: t2 p1 i2)) - (and (name-ref=? i1 i2) - (subtype t2 t1))] - [((NotTypeFilter: t2 p1 i2) - (NotTypeFilter: t1 p1 i1)) - (and (name-ref=? i1 i2) - (subtype t2 t1))] - [(_ _) #f]))) + (match* (f1 f2) + [(f f) #t] + [((Top:) _) #t] + [(_ (Bot:)) #t] + [((OrFilter: fs) f2) + (memf (lambda (f) (filter-equal? f f2)) fs)] + [((TypeFilter: t1 p1 i1) + (TypeFilter: t2 p1 i2)) + (and (name-ref=? i1 i2) + (subtype t2 t1))] + [((NotTypeFilter: t2 p1 i2) + (NotTypeFilter: t1 p1 i1)) + (and (name-ref=? i1 i2) + (subtype t2 t1))] + [(_ _) #f])) (define (hash-name-ref i) (if (identifier? i) (hash-id i) i)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/filter-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/filter-tests.rkt index c2bc0f47..5836ab74 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/filter-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/filter-tests.rkt @@ -39,8 +39,14 @@ -top -top) (check implied-atomic? -bot -bot) + (check implied-atomic? + -top -bot) (check not-implied-atomic? -bot -top) + (check implied-atomic? + -top (-filter -Symbol 0)) + (check implied-atomic? + (-filter -Symbol 0) -bot) (check implied-atomic? (-filter (Un -String -Symbol) 0) (-filter -Symbol 0))