Skip to content

Commit 632e1ff

Browse files
committed
[TypeChecker] NFC: Add a test-case for SR-12277
1 parent 89933c6 commit 632e1ff

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

test/Constraints/sr12277.swift

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
}

0 commit comments

Comments
 (0)