File tree Expand file tree Collapse file tree 3 files changed +48
-9
lines changed
typed-racket-lib/typed-racket
typed-racket-test/succeed Expand file tree Collapse file tree 3 files changed +48
-9
lines changed Original file line number Diff line number Diff line change 11
11
[->* t:->*]
12
12
[one-of/c t:one-of/c])
13
13
(private type-annotation syntax-properties)
14
- (types resolve type-table)
14
+ (types resolve type-table subtype )
15
15
(typecheck signatures tc-metafunctions tc-subst)
16
16
(env lexical-env tvar-env index-env scoped-tvar-env)
17
17
(utils tc-utils)
639
639
(match expected
640
640
[(tc-result1:(? DepFun? dep-fun-ty))
641
641
(tc/dep-lambda formalss bodies dep-fun-ty)]
642
- [_ (make-Fun
643
- (tc/mono-lambda
644
- (for/list ([f (in-syntax formalss)]
645
- [b (in-syntax bodies)])
646
- (cons (make-formals f not-in-poly) b))
647
- expected))]))
642
+ [_
643
+ (define arrs (tc/mono-lambda
644
+ (for/list ([f (in-syntax formalss)]
645
+ [b (in-syntax bodies)])
646
+ (cons (make-formals f not-in-poly) b))
647
+ expected))
648
+ (define arrs^ (append arrs (match (last arrs)
649
+ [(Arrow: dom (and (Rest: (list ty tys ... )) rst) kws rng)
650
+ (list (make-Arrow (dropf-right dom (lambda (x) (subtype ty x)))
651
+ rst
652
+ kws
653
+ rng))]
654
+ [_ null])))
655
+ (make-Fun arrs^)]))
656
+
648
657
649
658
(define (plambda-prop stx)
650
659
(define d (plambda-property stx))
Original file line number Diff line number Diff line change 7
7
(require "../utils/utils.rkt "
8
8
(utils prefab identifier)
9
9
racket/list
10
+ racket/lazy-require
10
11
syntax/id-set
11
12
racket/match
12
13
(prefix-in c: (contract-req))
24
25
25
26
(for-syntax racket/base syntax/parse))
26
27
28
+ (lazy-require ("subtype.rkt " (subtype)))
27
29
(provide (all-defined-out )
28
30
(all-from-out "base-abbrev.rkt " "match-expanders.rkt " ))
29
31
188
190
(define/decl -false-propset (-PS -ff -tt))
189
191
190
192
(define (opt-fn args opt-args result #:rest [rest #f ] #:kws [kws null])
191
- (apply cl->* (for/list ([i (in-range (add1 (length opt-args)))])
193
+ (define ret (for/list ([i (in-range (add1 (length opt-args)))])
192
194
(make-Fun (list (-Arrow (append args (take opt-args i))
193
195
result ;; only the LAST arrow gets the rest arg
194
196
#:rest (and (= i (length opt-args)) rest)
195
- #:kws kws))))))
197
+ #:kws kws)))))
198
+ (define ret^ (append ret (cond
199
+ [rest
200
+ (match-define (Rest: (list ty tys ... )) rest)
201
+ (list (make-Fun (list (-Arrow
202
+ (dropf-right opt-args (lambda (x) (subtype ty x)))
203
+ result
204
+ #:rest rest
205
+ #:kws kws))))]
206
+ [else null])))
207
+ (apply cl->* ret^))
196
208
197
209
(define-syntax-rule (->opt args ... [opt ... ] res)
198
210
(opt-fn (list args ... ) (list opt ... ) res))
Original file line number Diff line number Diff line change
1
+ #lang typed/racket
2
+
3
+ (: bar (-> (-> Natural * Any) Any))
4
+ (define (bar f)
5
+ 'any )
6
+
7
+ (: foo (-> (->* () (Integer Integer) #:rest Natural Any)
8
+ Any))
9
+ (define (foo f)
10
+ (bar f))
11
+
12
+ (: foo^ (-> Any * Any))
13
+ (define foo^
14
+ (case-lambda
15
+ [() 'one ]
16
+ [(a) 'two ]
17
+ [(a b . cs) 'three ]))
18
+
You can’t perform that action at this time.
0 commit comments