Skip to content

Commit 627d77b

Browse files
committed
Mark _NameMap and supporting types as Sendable.
I think this is the rest of the issues in apple#1560 This is the different approach discussed in apple#1564.
1 parent 033b0a2 commit 627d77b

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Sources/SwiftProtobuf/NameMap.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,18 @@ public struct _NameMap: ExpressibleByDictionaryLiteral {
308308
return jsonToNumberMap[n]
309309
}
310310
}
311+
312+
#if swift(>=5.5) && canImport(_Concurrency)
313+
// The `_NameMap` (and supporting types) are only mutated during their initial
314+
// creation, then for the lifetime of the a process they are constant. Swift
315+
// 5.10 flags the generated `_protobuf_nameMap` usages as a problem
316+
// (https://github.com/apple/swift-protobuf/issues/1560) so this silences those
317+
// warnings since the usage has been deemed safe.
318+
//
319+
// https://github.com/apple/swift-protobuf/issues/1561 is also opened to revisit
320+
// the `_NameMap` generally as it dates back to the days before Swift perferred
321+
// the UTF-8 internal encoding.
322+
extension _NameMap : Sendable {}
323+
extension _NameMap.Name : @unchecked Sendable {}
324+
extension InternPool : @unchecked Sendable {}
325+
#endif

0 commit comments

Comments
 (0)