Fix implied-atomic to work on -top and -bot.

original commit: 9e2787c0cf6eb3e45256ad31075978d3955ef34c
This commit is contained in:
Eric Dobson 2014-03-14 18:54:50 -07:00
parent 63bb9f5b5b
commit 3c2e254693
2 changed files with 21 additions and 14 deletions

View File

@ -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))

View File

@ -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))