Files
swift-mirror/test/Concurrency/startSynchronouslyIsolation.swift
Dario Rexin 35a44e5168 [Concurrency] Fix templated code in Task+startSynchronously.swift (#80100)
* [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
2025-03-20 18:29:31 -07:00

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 }
}
}