Skip to content

Commit ef7bb79

Browse files
committed
[Concurrency] ABI compat of typed throws and Task.value
1 parent bc028dc commit ef7bb79

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

stdlib/public/Concurrency/Task.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ extension Task {
166166
/// have that error propagated here upon cancellation.
167167
///
168168
/// - Returns: The task's result.
169+
@_alwaysEmitIntoClient
169170
public var value: Success {
170-
// FIXME: This seems wrong that abi test is not freaking out here?
171-
// At the same time, adding a silgen_name compat accessor with old signature results in duplicate definitions -- is mangling of typed throws not done properly on return position?
171+
@_silgen_name("$sScT7valueTTxvg") // "_t" suffix for the typed throws version
172172
get async throws(Failure) {
173173
do {
174174
return try await _taskFutureGetThrowing(_task)
@@ -178,6 +178,15 @@ extension Task {
178178
}
179179
}
180180

181+
// Legacy non-typed throws computed property
182+
@usableFromInline
183+
internal var __abi_value: Success {
184+
@_silgen_name("$sScT5valuexvg")
185+
get async throws {
186+
return try await _taskFutureGetThrowing(_task)
187+
}
188+
}
189+
181190
/// The result or error from a throwing task, after it completes.
182191
///
183192
/// If the task hasn't completed,
@@ -195,7 +204,7 @@ extension Task {
195204
do {
196205
return .success(try await value)
197206
} catch {
198-
return .failure(error as! Failure) // as!-safe, guaranteed to be Failure
207+
return .failure(error)
199208
}
200209
}
201210
}

test/abi/macOS/arm64/concurrency.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ Added: _swift_task_getPreferredTaskExecutor
270270
Added: _swift_task_popTaskExecutorPreference
271271
Added: _swift_task_pushTaskExecutorPreference
272272

273+
// Typed throws Task<Success, Failure>
274+
// property descriptor for Swift.Task.__abi_value : A
275+
Added: _$sScT11__abi_valuexvpMV
276+
273277
// Adopt #isolation in with...Continuation APIs
274278
// Swift.withCheckedThrowingContinuation<A>(isolation: isolated Swift.Actor?, function: Swift.String, _: (Swift.CheckedContinuation<A, Swift.Error>) -> ()) async throws -> A
275279
Added: _$ss31withCheckedThrowingContinuation9isolation8function_xScA_pSgYi_SSyScCyxs5Error_pGXEtYaKlF
@@ -322,4 +326,3 @@ Added: _$ss9TaskLocalC13withValueImpl_9operation9isolation4file4lineqd__xn_qd__y
322326
// Swift.TaskLocal.withValue<A>(_: A, operation: () async throws -> A1, isolation: isolated Swift.Actor?, file: Swift.String, line: Swift.UInt) async throws -> A1
323327
Added: _$ss9TaskLocalC9withValue_9operation9isolation4file4lineqd__x_qd__yYaKXEScA_pSgYiSSSutYaKlF
324328
Added: _$ss9TaskLocalC9withValue_9operation9isolation4file4lineqd__x_qd__yYaKXEScA_pSgYiSSSutYaKlFTu
325-

test/abi/macOS/x86_64/concurrency.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,10 @@ Added: _swift_task_getPreferredTaskExecutor
270270
Added: _swift_task_popTaskExecutorPreference
271271
Added: _swift_task_pushTaskExecutorPreference
272272

273+
// Typed throws Task<Success, Failure>
274+
// property descriptor for Swift.Task.__abi_value : A
275+
Added: _$sScT11__abi_valuexvpMV
276+
273277
// Adopt #isolation in with...Continuation APIs
274278
// Swift.withCheckedThrowingContinuation<A>(isolation: isolated Swift.Actor?, function: Swift.String, _: (Swift.CheckedContinuation<A, Swift.Error>) -> ()) async throws -> A
275279
Added: _$ss31withCheckedThrowingContinuation9isolation8function_xScA_pSgYi_SSyScCyxs5Error_pGXEtYaKlF

test/api-digester/stability-concurrency-abi.test

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,12 @@ Func TaskLocal.withValue(_:operation:file:line:) has parameter 1 type change fro
115115
Func TaskLocal.withValue(_:operation:file:line:) has parameter 2 type change from Swift.String to (any _Concurrency.Actor)?
116116
Func TaskLocal.withValue(_:operation:file:line:) has parameter 3 type change from Swift.UInt to Swift.String
117117

118+
// Adopt typed throws in Task<> and Task::value
119+
// (abi compat was handled but this test does not understand the silgen_name trickery)
120+
Accessor Task.value.Get() has mangled name changing from 'Swift.Task.value.getter : A' to 'Swift.Task.__abi_value.getter : A'
121+
Var Task.value has been renamed to Var __abi_value
122+
Var Task.value has mangled name changing from 'Swift.Task.value : A' to 'Swift.Task.__abi_value : A'
123+
118124
// *** DO NOT DISABLE OR XFAIL THIS TEST. *** (See comment above.)
119125

120126

0 commit comments

Comments
 (0)