Skip to content

Commit e422a9c

Browse files
committed
Apply @_unsafeInheritExecutor to with(Throwing)TaskGroup.
Fixes rdar://98461630.
1 parent 3a9211a commit e422a9c

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

stdlib/public/Concurrency/TaskGroup.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import Swift
6565
/// use the `withThrowingTaskGroup(of:returning:body:)` method instead.
6666
@available(SwiftStdlib 5.1, *)
6767
@_silgen_name("$ss13withTaskGroup2of9returning4bodyq_xm_q_mq_ScGyxGzYaXEtYar0_lF")
68+
@_unsafeInheritExecutor
6869
@inlinable
6970
public func withTaskGroup<ChildTaskResult, GroupResult>(
7071
of childTaskResultType: ChildTaskResult.Type,
@@ -157,6 +158,7 @@ public func withTaskGroup<ChildTaskResult, GroupResult>(
157158
/// or to let the group rethrow the error.
158159
@available(SwiftStdlib 5.1, *)
159160
@_silgen_name("$ss21withThrowingTaskGroup2of9returning4bodyq_xm_q_mq_Scgyxs5Error_pGzYaKXEtYaKr0_lF")
161+
@_unsafeInheritExecutor
160162
@inlinable
161163
public func withThrowingTaskGroup<ChildTaskResult, GroupResult>(
162164
of childTaskResultType: ChildTaskResult.Type,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %target-swift-frontend -typecheck -verify -disable-availability-checking %s -strict-concurrency=complete
2+
3+
actor A {
4+
func g() { }
5+
func h() throws { }
6+
7+
func f() async throws {
8+
await withTaskGroup(of: Int.self, returning: Void.self) { group in
9+
g()
10+
}
11+
12+
try await withThrowingTaskGroup(of: Int.self, returning: Void.self) { group in
13+
try h()
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)