Skip to content

Commit 1996b94

Browse files
committed
simplify code
1 parent 3e48d28 commit 1996b94

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

typed-racket-lib/typed-racket/infer/infer-unit.rkt

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -577,15 +577,14 @@
577577
[(F: v*) (and (bound-index? v*) (not (bound-tvar? v*)))]
578578
[_ #f])
579579
#f
580+
;; constrain v to be below T (but don't mention bounds)
580581
(define maybe-type-bound (hash-ref (context-type-bounds context) v #f))
581-
(if maybe-type-bound
582-
(if (subtype maybe-type-bound T obj)
583-
(singleton maybe-type-bound
584-
v
585-
(var-demote T (context-bounds context)))
586-
#f)
587-
;; constrain v to be below T (but don't mention bounds)
588-
(singleton -Bottom v (var-demote T (context-bounds context))))]
582+
(let ([sing (curryr singleton v (var-demote T (context-bounds context)))])
583+
(cond
584+
[(and maybe-type-bound (subtype maybe-type-bound T obj))
585+
(sing maybe-type-bound)]
586+
[(not maybe-type-bound) (sing -Bottom)]
587+
[else #f]))]
589588

590589
[(S (F: (? (inferable-var? context) v)))
591590
#:return-when
@@ -600,15 +599,7 @@
600599
[(and maybe-type-bound (subtype S maybe-type-bound obj))
601600
(sing maybe-type-bound)]
602601
[(not maybe-type-bound) (sing Univ)]
603-
[else #f]))
604-
#;
605-
(if maybe-type-bound
606-
(if (subtype S maybe-type-bound obj)
607-
(singleton (var-demote S (context-bounds context))
608-
v
609-
maybe-type-bound)
610-
#f)
611-
(singleton (var-promote S (context-bounds context)) v Univ))]
602+
[else #f]))]
612603

613604
;; recursive names should get resolved as they're seen
614605
[(s (? Name? t))

0 commit comments

Comments
 (0)