Skip to content

Commit 63be4bd

Browse files
authored
Revert some Sendable fixes around KeyPath while we sort out a compiler bug with ABI stability (#679)
1 parent b1acbaf commit 63be4bd

File tree

8 files changed

+109
-255
lines changed

8 files changed

+109
-255
lines changed

Sources/FoundationEssentials/AttributedString/AttributedString+AttributeTransformation.swift

Lines changed: 12 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,7 @@ extension AttributedString {
5252
andChanged changed: AttributedString.SingleAttributeTransformer<K>,
5353
to attrStr: inout AttributedString,
5454
key: K.Type
55-
)
56-
where
57-
K.Value : Sendable {
55+
) {
5856
if orig.range != changed.range || orig.attrName != changed.attrName {
5957
attrStr._guts.removeAttributeValue(forKey: K.self, in: orig.range._bstringRange) // If the range changed, we need to remove from the old range first.
6058
}
@@ -65,7 +63,7 @@ extension AttributedString {
6563
andChanged changed: AttributedString.SingleAttributeTransformer<K>,
6664
to attrStr: inout AttributedString,
6765
key: K.Type
68-
) where K.Value : Sendable {
66+
) {
6967
if orig.range != changed.range || orig.attrName != changed.attrName || orig.attr != changed.attr {
7068
if let newVal = changed.attr { // Then if there's a new value, we add it in.
7169
// Unfortunately, we can't use the attrStr[range].set() provided by the AttributedStringProtocol, because we *don't know* the new type statically!
@@ -80,13 +78,10 @@ extension AttributedString {
8078

8179
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
8280
extension AttributedString {
83-
@preconcurrency
8481
public func transformingAttributes<K>(
8582
_ k: K.Type,
8683
_ c: (inout AttributedString.SingleAttributeTransformer<K>) -> Void
87-
) -> AttributedString
88-
where
89-
K.Value : Sendable {
84+
) -> AttributedString {
9085
let orig = AttributedString(_guts)
9186
var copy = orig
9287
copy.ensureUniqueReference() // ???: Is this best practice? We're going behind the back of the AttributedString mutation API surface, so it doesn't happen anywhere else. It's also aggressively speculative.
@@ -100,16 +95,12 @@ extension AttributedString {
10095
return copy
10196
}
10297

103-
@preconcurrency
10498
public func transformingAttributes<K1, K2>(
10599
_ k: K1.Type,
106100
_ k2: K2.Type,
107101
_ c: (inout AttributedString.SingleAttributeTransformer<K1>,
108102
inout AttributedString.SingleAttributeTransformer<K2>) -> Void
109-
) -> AttributedString
110-
where
111-
K1.Value : Sendable,
112-
K2.Value : Sendable {
103+
) -> AttributedString {
113104
let orig = AttributedString(_guts)
114105
var copy = orig
115106
copy.ensureUniqueReference() // ???: Is this best practice? We're going behind the back of the AttributedString mutation API surface, so it doesn't happen anywhere else. It's also aggressively speculative.
@@ -127,19 +118,14 @@ extension AttributedString {
127118
return copy
128119
}
129120

130-
@preconcurrency
131121
public func transformingAttributes<K1, K2, K3>(
132122
_ k: K1.Type,
133123
_ k2: K2.Type,
134124
_ k3: K3.Type,
135125
_ c: (inout AttributedString.SingleAttributeTransformer<K1>,
136126
inout AttributedString.SingleAttributeTransformer<K2>,
137127
inout AttributedString.SingleAttributeTransformer<K3>) -> Void
138-
) -> AttributedString
139-
where
140-
K1.Value : Sendable,
141-
K2.Value : Sendable,
142-
K3.Value : Sendable {
128+
) -> AttributedString {
143129
let orig = AttributedString(_guts)
144130
var copy = orig
145131
copy.ensureUniqueReference() // ???: Is this best practice? We're going behind the back of the AttributedString mutation API surface, so it doesn't happen anywhere else. It's also aggressively speculative.
@@ -161,7 +147,6 @@ extension AttributedString {
161147
return copy
162148
}
163149

164-
@preconcurrency
165150
public func transformingAttributes<K1, K2, K3, K4>(
166151
_ k: K1.Type,
167152
_ k2: K2.Type,
@@ -171,12 +156,7 @@ extension AttributedString {
171156
inout AttributedString.SingleAttributeTransformer<K2>,
172157
inout AttributedString.SingleAttributeTransformer<K3>,
173158
inout AttributedString.SingleAttributeTransformer<K4>) -> Void
174-
) -> AttributedString
175-
where
176-
K1.Value : Sendable,
177-
K2.Value : Sendable,
178-
K3.Value : Sendable,
179-
K4.Value : Sendable {
159+
) -> AttributedString {
180160
let orig = AttributedString(_guts)
181161
var copy = orig
182162
copy.ensureUniqueReference() // ???: Is this best practice? We're going behind the back of the AttributedString mutation API surface, so it doesn't happen anywhere else. It's also aggressively speculative.
@@ -202,7 +182,6 @@ extension AttributedString {
202182
return copy
203183
}
204184

205-
@preconcurrency
206185
public func transformingAttributes<K1, K2, K3, K4, K5>(
207186
_ k: K1.Type,
208187
_ k2: K2.Type,
@@ -214,13 +193,7 @@ extension AttributedString {
214193
inout AttributedString.SingleAttributeTransformer<K3>,
215194
inout AttributedString.SingleAttributeTransformer<K4>,
216195
inout AttributedString.SingleAttributeTransformer<K5>) -> Void
217-
) -> AttributedString
218-
where
219-
K1.Value : Sendable,
220-
K2.Value : Sendable,
221-
K3.Value : Sendable,
222-
K4.Value : Sendable,
223-
K5.Value : Sendable {
196+
) -> AttributedString {
224197
let orig = AttributedString(_guts)
225198
var copy = orig
226199
copy.ensureUniqueReference() // ???: Is this best practice? We're going behind the back of the AttributedString mutation API surface, so it doesn't happen anywhere else. It's also aggressively speculative.
@@ -253,46 +226,33 @@ extension AttributedString {
253226

254227
@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *)
255228
extension AttributedString {
256-
@preconcurrency
257229
public func transformingAttributes<K>(
258230
_ k: KeyPath<AttributeDynamicLookup, K>,
259231
_ c: (inout AttributedString.SingleAttributeTransformer<K>) -> Void
260-
) -> AttributedString
261-
where
262-
K.Value : Sendable {
232+
) -> AttributedString {
263233
self.transformingAttributes(K.self, c)
264234
}
265235

266-
@preconcurrency
267236
public func transformingAttributes<K1, K2>(
268237
_ k: KeyPath<AttributeDynamicLookup, K1>,
269238
_ k2: KeyPath<AttributeDynamicLookup, K2>,
270239
_ c: (inout AttributedString.SingleAttributeTransformer<K1>,
271240
inout AttributedString.SingleAttributeTransformer<K2>) -> Void
272-
) -> AttributedString
273-
where
274-
K1.Value : Sendable,
275-
K2.Value : Sendable {
241+
) -> AttributedString {
276242
self.transformingAttributes(K1.self, K2.self, c)
277243
}
278244

279-
@preconcurrency
280245
public func transformingAttributes<K1, K2, K3>(
281246
_ k: KeyPath<AttributeDynamicLookup, K1>,
282247
_ k2: KeyPath<AttributeDynamicLookup, K2>,
283248
_ k3: KeyPath<AttributeDynamicLookup, K3>,
284249
_ c: (inout AttributedString.SingleAttributeTransformer<K1>,
285250
inout AttributedString.SingleAttributeTransformer<K2>,
286251
inout AttributedString.SingleAttributeTransformer<K3>) -> Void
287-
) -> AttributedString
288-
where
289-
K1.Value : Sendable,
290-
K2.Value : Sendable,
291-
K3.Value : Sendable {
252+
) -> AttributedString {
292253
self.transformingAttributes(K1.self, K2.self, K3.self, c)
293254
}
294255

295-
@preconcurrency
296256
public func transformingAttributes<K1, K2, K3, K4>(
297257
_ k: KeyPath<AttributeDynamicLookup, K1>,
298258
_ k2: KeyPath<AttributeDynamicLookup, K2>,
@@ -302,16 +262,10 @@ extension AttributedString {
302262
inout AttributedString.SingleAttributeTransformer<K2>,
303263
inout AttributedString.SingleAttributeTransformer<K3>,
304264
inout AttributedString.SingleAttributeTransformer<K4>) -> Void
305-
) -> AttributedString
306-
where
307-
K1.Value : Sendable,
308-
K2.Value : Sendable,
309-
K3.Value : Sendable,
310-
K4.Value : Sendable {
265+
) -> AttributedString {
311266
self.transformingAttributes(K1.self, K2.self, K3.self, K4.self, c)
312267
}
313268

314-
@preconcurrency
315269
public func transformingAttributes<K1, K2, K3, K4, K5>(
316270
_ k: KeyPath<AttributeDynamicLookup, K1>,
317271
_ k2: KeyPath<AttributeDynamicLookup, K2>,
@@ -323,13 +277,7 @@ extension AttributedString {
323277
inout AttributedString.SingleAttributeTransformer<K3>,
324278
inout AttributedString.SingleAttributeTransformer<K4>,
325279
inout AttributedString.SingleAttributeTransformer<K5>) -> Void
326-
) -> AttributedString
327-
where
328-
K1.Value : Sendable,
329-
K2.Value : Sendable,
330-
K3.Value : Sendable,
331-
K4.Value : Sendable,
332-
K5.Value : Sendable {
280+
) -> AttributedString {
333281
self.transformingAttributes(K1.self, K2.self, K3.self, K4.self, K5.self, c)
334282
}
335283
}

Sources/FoundationEssentials/AttributedString/AttributedString+Runs+AttributeSlices.swift

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,11 @@ extension AttributedString.Runs {
100100
// down to the nearest valid indices.
101101
}
102102

103-
@preconcurrency
104-
public subscript<T : AttributedStringKey>(_ keyPath: KeyPath<AttributeDynamicLookup, T>) -> AttributesSlice1<T> where T.Value : Sendable {
103+
public subscript<T : AttributedStringKey>(_ keyPath: KeyPath<AttributeDynamicLookup, T>) -> AttributesSlice1<T> {
105104
return AttributesSlice1<T>(runs: self)
106105
}
107106

108-
@preconcurrency
109-
public subscript<T : AttributedStringKey>(_ t: T.Type) -> AttributesSlice1<T> where T.Value : Sendable {
107+
public subscript<T : AttributedStringKey>(_ t: T.Type) -> AttributesSlice1<T> {
110108
return AttributesSlice1<T>(runs: self)
111109
}
112110
}
@@ -207,31 +205,23 @@ extension AttributedString.Runs {
207205
// down to the nearest valid indices.
208206
}
209207

210-
@preconcurrency
211208
public subscript <
212209
T : AttributedStringKey,
213210
U : AttributedStringKey
214211
> (
215212
_ t: KeyPath<AttributeDynamicLookup, T>,
216213
_ u: KeyPath<AttributeDynamicLookup, U>
217-
) -> AttributesSlice2<T, U>
218-
where
219-
T.Value : Sendable,
220-
U.Value : Sendable {
214+
) -> AttributesSlice2<T, U> {
221215
return AttributesSlice2<T, U>(runs: self)
222216
}
223217

224-
@preconcurrency
225218
public subscript <
226219
T : AttributedStringKey,
227220
U : AttributedStringKey
228221
> (
229222
_ t: T.Type,
230223
_ u: U.Type
231-
) -> AttributesSlice2<T, U>
232-
where
233-
T.Value : Sendable,
234-
U.Value : Sendable {
224+
) -> AttributesSlice2<T, U> {
235225
return AttributesSlice2<T, U>(runs: self)
236226
}
237227
}
@@ -338,7 +328,6 @@ extension AttributedString.Runs {
338328
// down to the nearest valid indices.
339329
}
340330

341-
@preconcurrency
342331
public subscript <
343332
T : AttributedStringKey,
344333
U : AttributedStringKey,
@@ -347,15 +336,10 @@ extension AttributedString.Runs {
347336
_ t: KeyPath<AttributeDynamicLookup, T>,
348337
_ u: KeyPath<AttributeDynamicLookup, U>,
349338
_ v: KeyPath<AttributeDynamicLookup, V>
350-
) -> AttributesSlice3<T, U, V>
351-
where
352-
T.Value : Sendable,
353-
U.Value : Sendable,
354-
V.Value : Sendable {
339+
) -> AttributesSlice3<T, U, V> {
355340
return AttributesSlice3<T, U, V>(runs: self)
356341
}
357342

358-
@preconcurrency
359343
public subscript <
360344
T : AttributedStringKey,
361345
U : AttributedStringKey,
@@ -364,11 +348,7 @@ extension AttributedString.Runs {
364348
_ t: T.Type,
365349
_ u: U.Type,
366350
_ v: V.Type
367-
) -> AttributesSlice3<T, U, V>
368-
where
369-
T.Value : Sendable,
370-
U.Value : Sendable,
371-
V.Value : Sendable {
351+
) -> AttributesSlice3<T, U, V> {
372352
return AttributesSlice3<T, U, V>(runs: self)
373353
}
374354
}
@@ -484,7 +464,6 @@ extension AttributedString.Runs {
484464
// down to the nearest valid indices.
485465
}
486466

487-
@preconcurrency
488467
public subscript <
489468
T : AttributedStringKey,
490469
U : AttributedStringKey,
@@ -499,7 +478,6 @@ extension AttributedString.Runs {
499478
return AttributesSlice4<T, U, V, W>(runs: self)
500479
}
501480

502-
@preconcurrency
503481
public subscript <
504482
T : AttributedStringKey,
505483
U : AttributedStringKey,
@@ -632,7 +610,6 @@ extension AttributedString.Runs {
632610
// down to the nearest valid indices.
633611
}
634612

635-
@preconcurrency
636613
public subscript <
637614
T : AttributedStringKey,
638615
U : AttributedStringKey,
@@ -645,17 +622,10 @@ extension AttributedString.Runs {
645622
_ v: KeyPath<AttributeDynamicLookup, V>,
646623
_ w: KeyPath<AttributeDynamicLookup, W>,
647624
_ x: KeyPath<AttributeDynamicLookup, X>
648-
) -> AttributesSlice5<T, U, V, W, X>
649-
where
650-
T.Value : Sendable,
651-
U.Value : Sendable,
652-
V.Value : Sendable,
653-
W.Value : Sendable,
654-
X.Value : Sendable {
625+
) -> AttributesSlice5<T, U, V, W, X> {
655626
return AttributesSlice5<T, U, V, W, X>(runs: self)
656627
}
657628

658-
@preconcurrency
659629
public subscript <
660630
T : AttributedStringKey,
661631
U : AttributedStringKey,
@@ -668,13 +638,7 @@ extension AttributedString.Runs {
668638
_ v: V.Type,
669639
_ w: W.Type,
670640
_ x: X.Type
671-
) -> AttributesSlice5<T, U, V, W, X>
672-
where
673-
T.Value : Sendable,
674-
U.Value : Sendable,
675-
V.Value : Sendable,
676-
W.Value : Sendable,
677-
X.Value : Sendable {
641+
) -> AttributesSlice5<T, U, V, W, X> {
678642
return AttributesSlice5<T, U, V, W, X>(runs: self)
679643
}
680644
}

0 commit comments

Comments
 (0)