- Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathasync_sequence_macosx.swift
35 lines (29 loc) · 961 Bytes
/
async_sequence_macosx.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// RUN: %target-swift-frontend -target %target-cpu-apple-macos14.0 %s -emit-sil -o /dev/null -verify -swift-version 6
// REQUIRES: concurrency, OS=macosx
func acceptClosure(_:()asyncthrows->Void){}
@available(macOS 13.0,*)
func f<S:AsyncSequence>(s:S)asyncthrows{
acceptClosure{
if #available(SwiftStdlib 6.0,*){
fortryawaitxin s {
print(x)
}
}
}
}
// Make sure we don't complain about crossing a concurrency boundary here.
@MainActor
classStore<Action:Sendable>{
privatefunc intercept(_ action:Action)asyncthrows{
awaitwithTaskGroup(of: Optional<Action>.self){ group in
forawaitcase let nextAction?in group {
_ = nextAction
}
}
tryawaitwithThrowingTaskGroup(of: Optional<Action>.self){ group in
fortryawaitcase let nextAction?in group {
_ = nextAction
}
}
}
}