@@ -64,8 +64,8 @@ import Swift
64
64
/// are created within that scope.
65
65
///
66
66
/// Detached tasks do not inherit task-local values, however tasks created using
67
- /// the `async { }` operation do inherit task-locals by copying them to the new
68
- /// asynchronous task, even though it is an un-structured task.
67
+ /// the `Task { ... }` initializer do inherit task-locals by copying them to the
68
+ /// new asynchronous task, even though it is an un-structured task.
69
69
///
70
70
/// ### Examples
71
71
///
@@ -78,12 +78,12 @@ import Swift
78
78
/// print("traceID: \(traceID)") // traceID: 1234
79
79
/// call() // traceID: 1234
80
80
///
81
- /// asyncDetached { // detached tasks do not inherit task-local values
82
- /// call() // traceID: nil
81
+ /// Task { // unstructured tasks do inherit task locals by copying
82
+ /// call() // traceID: 1234
83
83
/// }
84
84
///
85
- /// async { // async tasks do inherit task locals by copying
86
- /// call() // traceID: 1234
85
+ /// Task.detached { // detached tasks do not inherit task-local values
86
+ /// call() // traceID: nil
87
87
/// }
88
88
/// }
89
89
///
@@ -147,15 +147,16 @@ public final class TaskLocal<Value>: UnsafeSendable, CustomStringConvertible {
147
147
return try await operation ( )
148
148
}
149
149
150
- /// Binds the task-local to the specific value for the duration of the synchronous operation.
150
+ /// Binds the task-local to the specific value for the duration of the
151
+ /// synchronous operation.
151
152
///
152
153
/// The value is available throughout the execution of the operation closure,
153
154
/// including any `get` operations performed by child-tasks created during the
154
155
/// execution of the operation closure.
155
156
///
156
157
/// If the same task-local is bound multiple times, be it in the same task, or
157
- /// in specific child tasks, the more specific (i.e. "deeper") binding is
158
- /// returned when the value is read.
158
+ /// in specific child tasks, the " more specific" binding is returned when the
159
+ /// value is read.
159
160
///
160
161
/// If the value is a reference type, it will be retained for the duration of
161
162
/// the operation closure.
@@ -194,7 +195,7 @@ public final class TaskLocal<Value>: UnsafeSendable, CustomStringConvertible {
194
195
storage storageKeyPath: ReferenceWritableKeyPath < Never , TaskLocal < Value > >
195
196
) -> Value {
196
197
get {
197
- fatalError ( )
198
+ fatalError ( " Will never be executed, since enclosing instance is Never " )
198
199
}
199
200
}
200
201
0 commit comments