Update type-table after tc-funapp processing

This makes the tooltip show the more refined function
type after application typechecking. For example, case->
types will be narrowed to the particular case that fits.

Polymorphic function types will be instantiated at the
appropriate type.

Fixes issue #325
This commit is contained in:
Asumu Takikawa 2016-03-28 12:11:11 -04:00
parent cffad4df74
commit 9ec358b665
2 changed files with 10 additions and 2 deletions

View File

@ -7,7 +7,7 @@
(typecheck check-below tc-subst tc-metafunctions possible-domains)
(utils tc-utils)
(rep type-rep filter-rep)
(except-in (types utils abbrev subtype)
(except-in (types utils abbrev subtype type-table)
-> ->* one-of/c))
(require-for-cond-contract
syntax/stx)
@ -18,6 +18,8 @@
(#:check boolean?)
. ->* . full-tc-results/c)])
(define (tc/funapp1 f-stx args-stx ftype0 argtys expected #:check [check? #t])
;; update tooltip-table with inferred function type
(add-typeof-expr f-stx (ret (make-Function (list ftype0))))
(match* (ftype0 argtys)
;; we check that all kw args are optional
[((arr: dom rng rest #f (and kws (list (Keyword: _ _ #f) ...)))

View File

@ -100,4 +100,10 @@
(has-types-at? (list (list "^Integer$" 74 75))))
(check-tooltip (values 1 2)
(has-types-at? (list (list #rx"Value 1:.*One.*Value 2:.*Positive-Byte"
23 24))))))
23 24))))
(check-tooltip (identity 1)
(has-types-at? (list (list #rx"^\\(-> One One\\)$"
24 32))))
(check-tooltip (+ 1 2)
(has-types-at? (list (list #rx"^\\(-> Positive-Byte Positive-Byte Positive-Index\\)$"
24 25))))))