mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
* [Concurrency] Fix templated code in Task+startSynchronously.swift rdar://147348183 The gyb code always dropped the `throws` modifier, no matter which case was being processed. * Update Task+startSynchronously.swift.gyb * Fix abi tests
41 lines
1.2 KiB
Swift
41 lines
1.2 KiB
Swift
// RUN: %target-build-swift -swift-version 6 %s -strict-concurrency=complete -Xfrontend -verify
|
|
|
|
// REQUIRES: concurrency
|
|
|
|
@available(SwiftStdlib 6.2, *)
|
|
func sync() -> Task<String, Never> {
|
|
Task.startSynchronously {
|
|
return ""
|
|
}
|
|
}
|
|
|
|
@available(SwiftStdlib 6.2, *)
|
|
func async() async throws {
|
|
let t1 = Task.startSynchronously {
|
|
return ""
|
|
}
|
|
let _: String = await t1.value
|
|
|
|
let t2: Task<String, Error> = Task.startSynchronously {
|
|
throw CancellationError()
|
|
}
|
|
let _: String = try await t2.value
|
|
|
|
await withTaskGroup(of: Int.self) { group in
|
|
group.startTaskSynchronously { 1 }
|
|
group.startTaskSynchronouslyUnlessCancelled { 2 }
|
|
}
|
|
await withThrowingTaskGroup(of: Int.self) { group in
|
|
group.startTaskSynchronously { () async throws -> Int in 1 }
|
|
group.startTaskSynchronouslyUnlessCancelled { () async throws -> Int in 2 }
|
|
}
|
|
await withDiscardingTaskGroup { group in
|
|
group.startTaskSynchronously { }
|
|
group.startTaskSynchronouslyUnlessCancelled { }
|
|
}
|
|
try await withThrowingDiscardingTaskGroup { group in
|
|
group.startTaskSynchronously { () async throws -> Void in }
|
|
group.startTaskSynchronouslyUnlessCancelled { () async throws -> Void in }
|
|
}
|
|
}
|