File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ // RUN: %target-typecheck-verify-swift
2
+
3
+ enum Time {
4
+ case milliseconds( Int )
5
+ }
6
+
7
+ struct Scheduled < T> {
8
+ let futureResult : EventLoopFuture < T >
9
+ }
10
+
11
+ struct EventLoopFuture < T> {
12
+ func flatMap< V> ( _ body: @escaping ( T ) -> EventLoopFuture < V > ) -> EventLoopFuture < V > {
13
+ fatalError ( )
14
+ }
15
+ }
16
+
17
+ struct EventLoop {
18
+ func makeSucceededFuture< T> ( _ v: T ) -> EventLoopFuture < T > {
19
+ fatalError ( )
20
+ }
21
+
22
+ func scheduleTask< T> ( in t: Time , _ body: @escaping ( ) -> T ) -> Scheduled < T > {
23
+ fatalError ( )
24
+ }
25
+ }
26
+
27
+ struct Thing { }
28
+
29
+ func bar( eventLoop: EventLoop , process: @escaping ( Thing ) -> EventLoopFuture < Void > ) -> EventLoopFuture < Void > {
30
+ func doIt( thingsLeft: ArraySlice < Thing > ) -> EventLoopFuture < Void > {
31
+ var thingsLeft = thingsLeft
32
+ guard let first = thingsLeft. popFirst ( ) else {
33
+ return eventLoop. makeSucceededFuture ( ( ) )
34
+ }
35
+
36
+ return process ( first) . flatMap { [ thingsLeft] in
37
+ return eventLoop. scheduleTask ( in: . milliseconds( 100 ) ) {
38
+ return doIt ( thingsLeft: thingsLeft)
39
+ // expected-error@-1 {{cannot convert value of type 'EventLoopFuture<Void>' to closure result type 'Void'}}
40
+ } . futureResult
41
+ }
42
+ }
43
+
44
+ return doIt ( thingsLeft: [ ] [ ... ] )
45
+ }
You can’t perform that action at this time.
0 commit comments