@@ -259,8 +259,13 @@ public final class TaskLocal<Value: Sendable>: Sendable, CustomStringConvertible
259259 operation: ( ) async throws -> R ,
260260 isolation: isolated ( any Actor ) ? ,
261261 file: String = #fileID, line: UInt = #line) async rethrows -> R {
262+ #if $BuiltinConcurrencyStackNesting
262263 Builtin . taskLocalValuePush ( key, consume valueDuringOperation)
263264 defer { Builtin . taskLocalValuePop ( ) }
265+ #else
266+ _taskLocalValuePush ( key: key, value: consume valueDuringOperation)
267+ defer { _taskLocalValuePop ( ) }
268+ #endif
264269
265270 return try await operation ( )
266271 }
@@ -275,8 +280,13 @@ public final class TaskLocal<Value: Sendable>: Sendable, CustomStringConvertible
275280 operation: ( ) async throws -> R ,
276281 file: String = #fileID, line: UInt = #line
277282 ) async rethrows -> R {
283+ #if $BuiltinConcurrencyStackNesting
278284 Builtin . taskLocalValuePush ( key, consume valueDuringOperation)
279285 defer { Builtin . taskLocalValuePop ( ) }
286+ #else
287+ _taskLocalValuePush ( key: key, value: consume valueDuringOperation)
288+ defer { _taskLocalValuePop ( ) }
289+ #endif
280290
281291 return try await operation ( )
282292 }
@@ -299,8 +309,13 @@ public final class TaskLocal<Value: Sendable>: Sendable, CustomStringConvertible
299309 @discardableResult
300310 public func withValue< R> ( _ valueDuringOperation: Value , operation: ( ) throws -> R ,
301311 file: String = #fileID, line: UInt = #line) rethrows -> R {
312+ #if $BuiltinConcurrencyStackNesting
302313 Builtin . taskLocalValuePush ( key, valueDuringOperation)
303314 defer { Builtin . taskLocalValuePop ( ) }
315+ #else
316+ _taskLocalValuePush ( key: key, value: valueDuringOperation)
317+ defer { _taskLocalValuePop ( ) }
318+ #endif
304319
305320 return try operation ( )
306321 }
@@ -344,6 +359,19 @@ public final class TaskLocal<Value: Sendable>: Sendable, CustomStringConvertible
344359
345360// ==== ------------------------------------------------------------------------
346361
362+ @available ( SwiftStdlib 5 . 1 , * )
363+ @usableFromInline
364+ @_silgen_name ( " swift_task_localValuePush " )
365+ func _taskLocalValuePush< Value> (
366+ key: Builtin . RawPointer /*: Key*/,
367+ value: __owned Value
368+ ) // where Key: TaskLocal
369+
370+ @available( SwiftStdlib 5 . 1 , * )
371+ @usableFromInline
372+ @_silgen_name ( " swift_task_localValuePop " )
373+ func _taskLocalValuePop( )
374+
347375@available( SwiftStdlib 5 . 1 , * )
348376@_silgen_name ( " swift_task_localValueGet " )
349377func _taskLocalValueGet(
0 commit comments