From 688b640b31aa33b796b34ffc9cd944009770f6c4 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Fri, 15 Mar 2024 10:23:52 -0400 Subject: [PATCH] Mark `_NameMap` and supporting types as `Sendable`. I think this is the rest of the issues in #1560 This is the different approach discussed in #1564. --- Sources/SwiftProtobuf/NameMap.swift | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Sources/SwiftProtobuf/NameMap.swift b/Sources/SwiftProtobuf/NameMap.swift index e835c9899..1b0a83c3e 100644 --- a/Sources/SwiftProtobuf/NameMap.swift +++ b/Sources/SwiftProtobuf/NameMap.swift @@ -279,3 +279,16 @@ public struct _NameMap: ExpressibleByDictionaryLiteral { return jsonToNumberMap[n] } } + +// The `_NameMap` (and supporting types) are only mutated during their initial +// creation, then for the lifetime of the a process they are constant. Swift +// 5.10 flags the generated `_protobuf_nameMap` usages as a problem +// (https://github.com/apple/swift-protobuf/issues/1560) so this silences those +// warnings since the usage has been deemed safe. +// +// https://github.com/apple/swift-protobuf/issues/1561 is also opened to revisit +// the `_NameMap` generally as it dates back to the days before Swift perferred +// the UTF-8 internal encoding. +extension _NameMap : Sendable {} +extension _NameMap.Name : @unchecked Sendable {} +extension InternPool : @unchecked Sendable {}