File tree Expand file tree Collapse file tree 4 files changed +35
-11
lines changed
typed-racket-lib/typed-racket
typed-racket-test/succeed Expand file tree Collapse file tree 4 files changed +35
-11
lines changed Original file line number Diff line number Diff line change 1385
1385
(lambda (e)
1386
1386
(match-define (exn:fail:contract:arity:type-constructor _ _ expected given) e)
1387
1387
(err expected given))])
1388
- (define alias (lookup-type-alias #'id (lambda (x) x) (lambda () #f )))
1389
- (match alias
1390
- [(? Name?)
1391
- (if (equal? arity (length args^))
1392
- (make-App alias args^)
1393
- (err arity (length args^)))]
1394
- [_ (apply rator args^)]))]
1388
+ (cond
1389
+ ;; in the checking mode, inline type applications of simple
1390
+ ;; type constructors
1391
+ [(and (not mode)
1392
+ (simple-type-constructor? #'id ))
1393
+ (apply rator args^)]
1394
+ [else
1395
+ (define alias (lookup-type-alias #'id (lambda (x) x) (lambda () #f )))
1396
+ (match alias
1397
+ [(? Name?)
1398
+ (if (equal? arity (length args^))
1399
+ (make-App alias args^)
1400
+ (err arity (length args^)))]
1401
+ [_ (apply rator args^)])]))]
1395
1402
[(? Name?)
1396
1403
(resolve-app-check-error rator args^ stx)
1397
1404
(define app (make-App rator args^))
Original file line number Diff line number Diff line change 10
10
"../find-annotation.rkt "
11
11
"../tc-metafunctions.rkt "
12
12
"../../types/abbrev.rkt "
13
- "../../types/resolve.rkt "
14
13
"../../types/utils.rkt "
15
14
"../../types/generalize.rkt "
15
+ "../../types/resolve.rkt "
16
16
"../../types/type-table.rkt "
17
17
"../../private/type-annotation.rkt "
18
18
"../../private/syntax-properties.rkt "
109
109
(generalize (tc-expr/t ac)))))]
110
110
[acc-ty (or
111
111
(type-annotation #'val #:infer #t )
112
- (match (resolve expected)
113
- [(tc-result1: (app resolve (and t (Listof: _ )))) t]
112
+ (match expected
113
+ [(tc-result1: (and t (or (? App? (app resolve-once (Listof: _ ))) (Listof: _ ))))
114
+ t]
114
115
[_ #f ])
115
116
(generalize -Null))])
116
117
;; this check is needed because the type annotation may come
Original file line number Diff line number Diff line change 12
12
"../../types/type-table.rkt "
13
13
"../../types/utils.rkt "
14
14
"../../types/substitute.rkt "
15
+ "../../types/resolve.rkt "
15
16
"../../rep/type-rep.rkt "
16
17
"../../env/tvar-env.rkt "
17
18
(prefix-in i: "../../infer/infer.rkt " )
154
155
;; special case for `reverse' to propagate expected type info
155
156
(pattern ((~and fun (~or reverse k:reverse)) arg)
156
157
(match expected
157
- [(tc-result1: (and return-ty (Listof: _ )))
158
+ [(tc-result1: (and return-ty (or (? App? (app resolve-once ( Listof: _ ))) (Listof: _ ) )))
158
159
(begin0
159
160
(tc-expr/check #'arg expected)
160
161
(add-typeof-expr #'fun (ret (-> return-ty return-ty))))]
Original file line number Diff line number Diff line change
1
+ #lang typed/racket
2
+
3
+ (define-type (Assoc X Y) (Listof (Pairof X Y)))
4
+
5
+ (: f : (Listof Integer) (Listof String) -> (Listof (Pairof Integer String)))
6
+ (define (f l m)
7
+ (for/list : (Assoc Integer String) ([x : Integer (in-list l)]
8
+ [y : String (in-list m)])
9
+ (cons x y)))
10
+
11
+
12
+ (define (g [l : (Listof Integer)] [m : (Listof String)]) : (Assoc Integer String)
13
+ (for/list ([x (in-list l)]
14
+ [y (in-list m)])
15
+ (cons x y)))
You can’t perform that action at this time.
0 commit comments