From fdcd5f3a037e974902b6528bd367c22dff61d462 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Thu, 29 Feb 2024 14:54:07 -0500 Subject: [PATCH 1/3] For Swift 5.10, mark Storage `defaultInstance` `nonisolated(unsafe)` - Update AnyMessageStorage.swift - Update the generator. --- Sources/SwiftProtobuf/AnyMessageStorage.swift | 10 +++++++++- .../MessageStorageClassGenerator.swift | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Sources/SwiftProtobuf/AnyMessageStorage.swift b/Sources/SwiftProtobuf/AnyMessageStorage.swift index 551c0fbaf..14c272493 100644 --- a/Sources/SwiftProtobuf/AnyMessageStorage.swift +++ b/Sources/SwiftProtobuf/AnyMessageStorage.swift @@ -146,7 +146,15 @@ internal class AnyMessageStorage { } var state: InternalState = .binary(Data()) - static let defaultInstance = AnyMessageStorage() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = AnyMessageStorage() + #else + static let defaultInstance = AnyMessageStorage() + #endif private init() {} diff --git a/Sources/protoc-gen-swift/MessageStorageClassGenerator.swift b/Sources/protoc-gen-swift/MessageStorageClassGenerator.swift index 34fe7baa4..aab02b9f3 100644 --- a/Sources/protoc-gen-swift/MessageStorageClassGenerator.swift +++ b/Sources/protoc-gen-swift/MessageStorageClassGenerator.swift @@ -51,7 +51,15 @@ class MessageStorageClassGenerator { // readonly usage never causes the allocation. p.print( "\n", - "static let defaultInstance = _StorageClass()\n", + "#if swift(>=5.10)\n", + " // This property is used as the initial default value for new instances of the type.\n", + " // The type itself is protecting the reference to its storage via CoW semantics.\n", + " // This will force a copy to be made of this reference when the first mutation occurs;\n", + " // hence, it is safe to mark this as `nonisolated(unsafe)`.\n", + " static nonisolated(unsafe) let defaultInstance = _StorageClass()\n", + "#else\n", + " static let defaultInstance = _StorageClass()\n", + "#endif\n", "\n", "private init() {}\n", "\n") From 033b0a288d0c6e773fa3e5bf15d2c3d5f7e44272 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Tue, 19 Mar 2024 09:16:43 -0400 Subject: [PATCH 2/3] Regenerate. --- .../Sources/FuzzCommon/fuzz_testing.pb.swift | 10 +- .../protobuf/test_messages_proto2.pb.swift | 40 ++++- .../protobuf/test_messages_proto3.pb.swift | 20 ++- .../google/protobuf/descriptor.pb.swift | 30 +++- .../pluginlib_descriptor_test.pb.swift | 30 +++- .../SwiftProtobufTests/fuzz_testing.pb.swift | 10 +- .../generated_swift_names_fields.pb.swift | 10 +- .../SwiftProtobufTests/map_unittest.pb.swift | 10 +- .../test_messages_proto3.pb.swift | 20 ++- .../SwiftProtobufTests/unittest.pb.swift | 50 +++++- .../unittest_proto3.pb.swift | 20 ++- .../unittest_proto3_optional.pb.swift | 10 +- ...unittest_swift_all_required_types.pb.swift | 10 +- .../unittest_swift_cycle.pb.swift | 30 +++- ...ttest_swift_enum_optional_default.pb.swift | 10 +- .../unittest_swift_extension.pb.swift | 10 +- .../unittest_swift_naming.pb.swift | 40 ++++- .../unittest_swift_runtime_proto2.pb.swift | 20 ++- .../unittest_swift_runtime_proto3.pb.swift | 20 ++- .../unittest_well_known_types.pb.swift | 30 +++- .../google/protobuf/descriptor.pb.swift | 30 +++- .../protobuf/map_lite_unittest.pb.swift | 20 ++- .../google/protobuf/map_unittest.pb.swift | 20 ++- .../protobuf/test_messages_proto2.pb.swift | 40 ++++- .../protobuf/test_messages_proto3.pb.swift | 20 ++- .../google/protobuf/unittest.pb.swift | 160 ++++++++++++++++-- .../protobuf/unittest_custom_options.pb.swift | 10 +- .../unittest_enormous_descriptor.pb.swift | 10 +- .../protobuf/unittest_features.pb.swift | 10 +- .../google/protobuf/unittest_lite.pb.swift | 30 +++- .../google/protobuf/unittest_mset.pb.swift | 20 ++- .../unittest_no_field_presence.pb.swift | 10 +- .../google/protobuf/unittest_proto3.pb.swift | 20 ++- .../protobuf/unittest_proto3_arena.pb.swift | 20 ++- .../unittest_proto3_arena_lite.pb.swift | 20 ++- .../protobuf/unittest_proto3_lite.pb.swift | 20 ++- .../unittest_proto3_optional.pb.swift | 10 +- .../unittest_well_known_types.pb.swift | 30 +++- .../Conformance/test_messages_proto2.pb.swift | 40 ++++- .../Conformance/test_messages_proto3.pb.swift | 20 ++- Sources/SwiftProtobuf/descriptor.pb.swift | 30 +++- .../SwiftProtobufTests/fuzz_testing.pb.swift | 10 +- .../generated_swift_names_fields.pb.swift | 10 +- .../SwiftProtobufTests/map_unittest.pb.swift | 10 +- .../test_messages_proto3.pb.swift | 20 ++- Tests/SwiftProtobufTests/unittest.pb.swift | 50 +++++- .../unittest_proto3.pb.swift | 20 ++- .../unittest_proto3_optional.pb.swift | 10 +- ...unittest_swift_all_required_types.pb.swift | 10 +- .../unittest_swift_cycle.pb.swift | 30 +++- ...ttest_swift_enum_optional_default.pb.swift | 10 +- .../unittest_swift_extension.pb.swift | 10 +- .../unittest_swift_naming.pb.swift | 40 ++++- .../unittest_swift_runtime_proto2.pb.swift | 20 ++- .../unittest_swift_runtime_proto3.pb.swift | 20 ++- .../unittest_well_known_types.pb.swift | 30 +++- 56 files changed, 1188 insertions(+), 132 deletions(-) diff --git a/FuzzTesting/Sources/FuzzCommon/fuzz_testing.pb.swift b/FuzzTesting/Sources/FuzzCommon/fuzz_testing.pb.swift index 9ebf3ef12..fdf65869d 100644 --- a/FuzzTesting/Sources/FuzzCommon/fuzz_testing.pb.swift +++ b/FuzzTesting/Sources/FuzzCommon/fuzz_testing.pb.swift @@ -3551,7 +3551,15 @@ extension Fuzz_Testing_Message: SwiftProtobuf.Message, SwiftProtobuf._MessageImp var _singularMessageSet: Fuzz_Testing_AMessageSetMessage? = nil var _repeatedMessageSet: [Fuzz_Testing_AMessageSetMessage] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/Conformance/google/protobuf/test_messages_proto2.pb.swift b/Reference/Conformance/google/protobuf/test_messages_proto2.pb.swift index 60c7b15cd..ca1dfd606 100644 --- a/Reference/Conformance/google/protobuf/test_messages_proto2.pb.swift +++ b/Reference/Conformance/google/protobuf/test_messages_proto2.pb.swift @@ -2446,7 +2446,15 @@ extension ProtobufTestMessages_Proto2_TestAllTypesProto2: SwiftProtobuf.Message, var _fieldName17__: Int32? = nil var _fieldName18__: Int32? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -3397,7 +3405,15 @@ extension ProtobufTestMessages_Proto2_TestAllTypesProto2.NestedMessage: SwiftPro var _a: Int32? = nil var _corecursive: ProtobufTestMessages_Proto2_TestAllTypesProto2? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -3960,7 +3976,15 @@ extension ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2: SwiftProtobuf. var _defaultString: String? = nil var _defaultBytes: Data? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -4322,7 +4346,15 @@ extension ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2.NestedMessage: var _corecursive: ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2? = nil var _optionalCorecursive: ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/Conformance/google/protobuf/test_messages_proto3.pb.swift b/Reference/Conformance/google/protobuf/test_messages_proto3.pb.swift index 8ca649b5e..cdd42a36b 100644 --- a/Reference/Conformance/google/protobuf/test_messages_proto3.pb.swift +++ b/Reference/Conformance/google/protobuf/test_messages_proto3.pb.swift @@ -1545,7 +1545,15 @@ extension ProtobufTestMessages_Proto3_TestAllTypesProto3: SwiftProtobuf.Message, var _fieldName17__: Int32 = 0 var _fieldName18__: Int32 = 0 - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -2602,7 +2610,15 @@ extension ProtobufTestMessages_Proto3_TestAllTypesProto3.NestedMessage: SwiftPro var _a: Int32 = 0 var _corecursive: ProtobufTestMessages_Proto3_TestAllTypesProto3? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobuf/google/protobuf/descriptor.pb.swift b/Reference/SwiftProtobuf/google/protobuf/descriptor.pb.swift index 664fb13a8..7c8b09661 100644 --- a/Reference/SwiftProtobuf/google/protobuf/descriptor.pb.swift +++ b/Reference/SwiftProtobuf/google/protobuf/descriptor.pb.swift @@ -3261,7 +3261,15 @@ extension Google_Protobuf_DescriptorProto: SwiftProtobuf.Message, SwiftProtobuf. var _reservedRange: [Google_Protobuf_DescriptorProto.ReservedRange] = [] var _reservedName: [String] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -4128,7 +4136,15 @@ extension Google_Protobuf_FileOptions: SwiftProtobuf.Message, SwiftProtobuf._Mes var _features: Google_Protobuf_FeatureSet? = nil var _uninterpretedOption: [Google_Protobuf_UninterpretedOption] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -4444,7 +4460,15 @@ extension Google_Protobuf_FieldOptions: SwiftProtobuf.Message, SwiftProtobuf._Me var _features: Google_Protobuf_FeatureSet? = nil var _uninterpretedOption: [Google_Protobuf_UninterpretedOption] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufPluginLibraryTests/pluginlib_descriptor_test.pb.swift b/Reference/SwiftProtobufPluginLibraryTests/pluginlib_descriptor_test.pb.swift index b67f05f3d..bce2f6e10 100644 --- a/Reference/SwiftProtobufPluginLibraryTests/pluginlib_descriptor_test.pb.swift +++ b/Reference/SwiftProtobufPluginLibraryTests/pluginlib_descriptor_test.pb.swift @@ -768,7 +768,15 @@ extension SDTTopLevelMessage: SwiftProtobuf.Message, SwiftProtobuf._MessageImple var _field2: Int32? = nil var _o: SDTTopLevelMessage.OneOf_O? - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -917,7 +925,15 @@ extension SDTTopLevelMessage.SubMessage: SwiftProtobuf.Message, SwiftProtobuf._M var _field2: String? = nil var _field3: SDTTopLevelMessage.SubMessage? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -999,7 +1015,15 @@ extension SDTTopLevelMessage2: SwiftProtobuf.Message, SwiftProtobuf._MessageImpl var _left: SDTTopLevelMessage? = nil var _right: SDTTopLevelMessage2? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/fuzz_testing.pb.swift b/Reference/SwiftProtobufTests/fuzz_testing.pb.swift index 992e746d6..0e298a49d 100644 --- a/Reference/SwiftProtobufTests/fuzz_testing.pb.swift +++ b/Reference/SwiftProtobufTests/fuzz_testing.pb.swift @@ -3551,7 +3551,15 @@ extension Fuzz_Testing_Message: SwiftProtobuf.Message, SwiftProtobuf._MessageImp var _singularMessageSet: Fuzz_Testing_AMessageSetMessage? = nil var _repeatedMessageSet: [Fuzz_Testing_AMessageSetMessage] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/generated_swift_names_fields.pb.swift b/Reference/SwiftProtobufTests/generated_swift_names_fields.pb.swift index 09a4d1732..c05eb99f4 100644 --- a/Reference/SwiftProtobufTests/generated_swift_names_fields.pb.swift +++ b/Reference/SwiftProtobufTests/generated_swift_names_fields.pb.swift @@ -6666,7 +6666,15 @@ extension ProtobufUnittestGenerated_GeneratedSwiftReservedFields: SwiftProtobuf. var _written: Int32 = 0 var _yday: Int32 = 0 - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/map_unittest.pb.swift b/Reference/SwiftProtobufTests/map_unittest.pb.swift index e1fb0db41..6629a6d7d 100644 --- a/Reference/SwiftProtobufTests/map_unittest.pb.swift +++ b/Reference/SwiftProtobufTests/map_unittest.pb.swift @@ -291,7 +291,15 @@ extension ProtobufUnittest_TestMap: SwiftProtobuf.Message, SwiftProtobuf._Messag var _mapStringForeignMessage: Dictionary = [:] var _mapInt32AllTypes: Dictionary = [:] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/test_messages_proto3.pb.swift b/Reference/SwiftProtobufTests/test_messages_proto3.pb.swift index 2b2aa9a40..5bbc7155c 100644 --- a/Reference/SwiftProtobufTests/test_messages_proto3.pb.swift +++ b/Reference/SwiftProtobufTests/test_messages_proto3.pb.swift @@ -1100,7 +1100,15 @@ extension ProtobufTestMessages_Proto3_TestAllTypesProto3: SwiftProtobuf.Message, var _fieldName17__: Int32 = 0 var _fieldName18__: Int32 = 0 - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1909,7 +1917,15 @@ extension ProtobufTestMessages_Proto3_TestAllTypesProto3.NestedMessage: SwiftPro var _a: Int32 = 0 var _corecursive: ProtobufTestMessages_Proto3_TestAllTypesProto3? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/unittest.pb.swift b/Reference/SwiftProtobufTests/unittest.pb.swift index 2fe7aed13..a112531a4 100644 --- a/Reference/SwiftProtobufTests/unittest.pb.swift +++ b/Reference/SwiftProtobufTests/unittest.pb.swift @@ -4681,7 +4681,15 @@ extension ProtobufUnittest_TestAllTypes: SwiftProtobuf.Message, SwiftProtobuf._M var _defaultCord: String? = nil var _oneofField: ProtobufUnittest_TestAllTypes.OneOf_OneofField? - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -5358,7 +5366,15 @@ extension ProtobufUnittest_NestedTestAllTypes: SwiftProtobuf.Message, SwiftProto var _lazyChild: ProtobufUnittest_NestedTestAllTypes? = nil var _eagerChild: ProtobufUnittest_TestAllTypes? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -5678,7 +5694,15 @@ extension ProtobufUnittest_TestRequired: SwiftProtobuf.Message, SwiftProtobuf._M var _c: Int32? = nil var _optionalForeign: ProtobufUnittest_ForeignMessage? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -6132,7 +6156,15 @@ extension ProtobufUnittest_TestRecursiveMessage: SwiftProtobuf.Message, SwiftPro var _a: ProtobufUnittest_TestRecursiveMessage? = nil var _i: Int32? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -6364,7 +6396,15 @@ extension ProtobufUnittest_TestExtremeDefaultValues: SwiftProtobuf.Message, Swif var _cordWithZero: String? = nil var _replacementString: String? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/unittest_proto3.pb.swift b/Reference/SwiftProtobufTests/unittest_proto3.pb.swift index a6000df4c..14a67e159 100644 --- a/Reference/SwiftProtobufTests/unittest_proto3.pb.swift +++ b/Reference/SwiftProtobufTests/unittest_proto3.pb.swift @@ -820,7 +820,15 @@ extension Proto3Unittest_TestAllTypes: SwiftProtobuf.Message, SwiftProtobuf._Mes var _repeatedLazyMessage: [Proto3Unittest_TestAllTypes.NestedMessage] = [] var _oneofField: Proto3Unittest_TestAllTypes.OneOf_OneofField? - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1498,7 +1506,15 @@ extension Proto3Unittest_NestedTestAllTypes: SwiftProtobuf.Message, SwiftProtobu var _child: Proto3Unittest_NestedTestAllTypes? = nil var _payload: Proto3Unittest_TestAllTypes? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/unittest_proto3_optional.pb.swift b/Reference/SwiftProtobufTests/unittest_proto3_optional.pb.swift index b949a4ed1..199d35607 100644 --- a/Reference/SwiftProtobufTests/unittest_proto3_optional.pb.swift +++ b/Reference/SwiftProtobufTests/unittest_proto3_optional.pb.swift @@ -382,7 +382,15 @@ extension ProtobufUnittest_TestProto3Optional: SwiftProtobuf.Message, SwiftProto var _singularInt32: Int32 = 0 var _singularInt64: Int64 = 0 - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/unittest_swift_all_required_types.pb.swift b/Reference/SwiftProtobufTests/unittest_swift_all_required_types.pb.swift index 8100bd2ad..dd0c1e6b4 100644 --- a/Reference/SwiftProtobufTests/unittest_swift_all_required_types.pb.swift +++ b/Reference/SwiftProtobufTests/unittest_swift_all_required_types.pb.swift @@ -867,7 +867,15 @@ extension ProtobufUnittest_TestAllRequiredTypes: SwiftProtobuf.Message, SwiftPro var _defaultCord: String? = nil var _oneofField: ProtobufUnittest_TestAllRequiredTypes.OneOf_OneofField? - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/unittest_swift_cycle.pb.swift b/Reference/SwiftProtobufTests/unittest_swift_cycle.pb.swift index 87145ef2b..76049b987 100644 --- a/Reference/SwiftProtobufTests/unittest_swift_cycle.pb.swift +++ b/Reference/SwiftProtobufTests/unittest_swift_cycle.pb.swift @@ -189,7 +189,15 @@ extension ProtobufUnittest_CycleFoo: SwiftProtobuf.Message, SwiftProtobuf._Messa var _aBar: ProtobufUnittest_CycleBar? = nil var _aBaz: ProtobufUnittest_CycleBaz? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -273,7 +281,15 @@ extension ProtobufUnittest_CycleBar: SwiftProtobuf.Message, SwiftProtobuf._Messa var _aBaz: ProtobufUnittest_CycleBaz? = nil var _aFoo: ProtobufUnittest_CycleFoo? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -357,7 +373,15 @@ extension ProtobufUnittest_CycleBaz: SwiftProtobuf.Message, SwiftProtobuf._Messa var _aFoo: ProtobufUnittest_CycleFoo? = nil var _aBar: ProtobufUnittest_CycleBar? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/unittest_swift_enum_optional_default.pb.swift b/Reference/SwiftProtobufTests/unittest_swift_enum_optional_default.pb.swift index b731aa90c..e2678cf04 100644 --- a/Reference/SwiftProtobufTests/unittest_swift_enum_optional_default.pb.swift +++ b/Reference/SwiftProtobufTests/unittest_swift_enum_optional_default.pb.swift @@ -199,7 +199,15 @@ extension ProtobufUnittest_Extend_EnumOptionalDefault.NestedMessage: SwiftProtob var _message: ProtobufUnittest_Extend_EnumOptionalDefault.NestedMessage? = nil var _optionalEnum: ProtobufUnittest_Extend_EnumOptionalDefault.NestedMessage.Enum? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/unittest_swift_extension.pb.swift b/Reference/SwiftProtobufTests/unittest_swift_extension.pb.swift index 3783af78a..606f730c5 100644 --- a/Reference/SwiftProtobufTests/unittest_swift_extension.pb.swift +++ b/Reference/SwiftProtobufTests/unittest_swift_extension.pb.swift @@ -653,7 +653,15 @@ extension ProtobufUnittest_Extend_MsgUsesStorage: SwiftProtobuf.Message, SwiftPr var _x: Int32? = nil var _y: ProtobufUnittest_Extend_MsgUsesStorage? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/unittest_swift_naming.pb.swift b/Reference/SwiftProtobufTests/unittest_swift_naming.pb.swift index 7917b9a9f..72d7b1c28 100644 --- a/Reference/SwiftProtobufTests/unittest_swift_naming.pb.swift +++ b/Reference/SwiftProtobufTests/unittest_swift_naming.pb.swift @@ -17216,7 +17216,15 @@ extension SwiftUnittest_Names_FieldNames: SwiftProtobuf.Message, SwiftProtobuf._ var _extension: Int32? = nil var _extensions: Int32? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -27669,7 +27677,15 @@ extension SwiftUnittest_Names_FieldNamingInitials.Lowers: SwiftProtobuf.Message, var _theIDNumber: Int32? = nil var _requestID: Int32? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -28432,7 +28448,15 @@ extension SwiftUnittest_Names_SpecialNames3: SwiftProtobuf.Message, SwiftProtobu var _newValue: SwiftUnittest_Names_SpecialNames3.OneOf_NewValue? var _forcesStorage: SwiftUnittest_Names_SpecialNames3? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -28515,7 +28539,15 @@ extension SwiftUnittest_Names_SpecialNames4: SwiftProtobuf.Message, SwiftProtobu var _newValue: String? = nil var _forcesStorage: SwiftUnittest_Names_SpecialNames4? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/unittest_swift_runtime_proto2.pb.swift b/Reference/SwiftProtobufTests/unittest_swift_runtime_proto2.pb.swift index ec106e899..e007c9f1b 100644 --- a/Reference/SwiftProtobufTests/unittest_swift_runtime_proto2.pb.swift +++ b/Reference/SwiftProtobufTests/unittest_swift_runtime_proto2.pb.swift @@ -1045,7 +1045,15 @@ extension ProtobufUnittest_Message2: SwiftProtobuf.Message, SwiftProtobuf._Messa var _mapInt32Enum: Dictionary = [:] var _mapInt32Message: Dictionary = [:] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1810,7 +1818,15 @@ extension ProtobufUnittest_Msg2UsesStorage: SwiftProtobuf.Message, SwiftProtobuf fileprivate class _StorageClass { var _y: ProtobufUnittest_Msg2UsesStorage? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/unittest_swift_runtime_proto3.pb.swift b/Reference/SwiftProtobufTests/unittest_swift_runtime_proto3.pb.swift index 8589ebd19..a9202e65a 100644 --- a/Reference/SwiftProtobufTests/unittest_swift_runtime_proto3.pb.swift +++ b/Reference/SwiftProtobufTests/unittest_swift_runtime_proto3.pb.swift @@ -844,7 +844,15 @@ extension ProtobufUnittest_Message3: SwiftProtobuf.Message, SwiftProtobuf._Messa var _mapInt32Enum: Dictionary = [:] var _mapInt32Message: Dictionary = [:] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1466,7 +1474,15 @@ extension ProtobufUnittest_Msg3UsesStorage: SwiftProtobuf.Message, SwiftProtobuf fileprivate class _StorageClass { var _y: ProtobufUnittest_Msg3UsesStorage? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/SwiftProtobufTests/unittest_well_known_types.pb.swift b/Reference/SwiftProtobufTests/unittest_well_known_types.pb.swift index bce16661e..f8671c1b4 100644 --- a/Reference/SwiftProtobufTests/unittest_well_known_types.pb.swift +++ b/Reference/SwiftProtobufTests/unittest_well_known_types.pb.swift @@ -763,7 +763,15 @@ extension ProtobufUnittest_TestWellKnownTypes: SwiftProtobuf.Message, SwiftProto var _bytesField: SwiftProtobuf.Google_Protobuf_BytesValue? = nil var _valueField: SwiftProtobuf.Google_Protobuf_Value? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -973,7 +981,15 @@ extension ProtobufUnittest_RepeatedWellKnownTypes: SwiftProtobuf.Message, SwiftP var _stringField: [SwiftProtobuf.Google_Protobuf_StringValue] = [] var _bytesField: [SwiftProtobuf.Google_Protobuf_BytesValue] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1531,7 +1547,15 @@ extension ProtobufUnittest_MapWellKnownTypes: SwiftProtobuf.Message, SwiftProtob var _stringField: Dictionary = [:] var _bytesField: Dictionary = [:] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/descriptor.pb.swift b/Reference/upstream/google/protobuf/descriptor.pb.swift index 664fb13a8..7c8b09661 100644 --- a/Reference/upstream/google/protobuf/descriptor.pb.swift +++ b/Reference/upstream/google/protobuf/descriptor.pb.swift @@ -3261,7 +3261,15 @@ extension Google_Protobuf_DescriptorProto: SwiftProtobuf.Message, SwiftProtobuf. var _reservedRange: [Google_Protobuf_DescriptorProto.ReservedRange] = [] var _reservedName: [String] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -4128,7 +4136,15 @@ extension Google_Protobuf_FileOptions: SwiftProtobuf.Message, SwiftProtobuf._Mes var _features: Google_Protobuf_FeatureSet? = nil var _uninterpretedOption: [Google_Protobuf_UninterpretedOption] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -4444,7 +4460,15 @@ extension Google_Protobuf_FieldOptions: SwiftProtobuf.Message, SwiftProtobuf._Me var _features: Google_Protobuf_FeatureSet? = nil var _uninterpretedOption: [Google_Protobuf_UninterpretedOption] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/map_lite_unittest.pb.swift b/Reference/upstream/google/protobuf/map_lite_unittest.pb.swift index e909adb1d..01715853e 100644 --- a/Reference/upstream/google/protobuf/map_lite_unittest.pb.swift +++ b/Reference/upstream/google/protobuf/map_lite_unittest.pb.swift @@ -592,7 +592,15 @@ extension ProtobufUnittest_TestMapLite: SwiftProtobuf.Message, SwiftProtobuf._Me var _mapInt32ForeignMessage: Dictionary = [:] var _teboring: Dictionary = [:] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -790,7 +798,15 @@ extension ProtobufUnittest_TestArenaMapLite: SwiftProtobuf.Message, SwiftProtobu var _mapInt32Enum: Dictionary = [:] var _mapInt32ForeignMessage: Dictionary = [:] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/map_unittest.pb.swift b/Reference/upstream/google/protobuf/map_unittest.pb.swift index 659194317..1bc01ec47 100644 --- a/Reference/upstream/google/protobuf/map_unittest.pb.swift +++ b/Reference/upstream/google/protobuf/map_unittest.pb.swift @@ -531,7 +531,15 @@ extension ProtobufUnittest_TestMap: SwiftProtobuf.Message, SwiftProtobuf._Messag var _mapStringForeignMessage: Dictionary = [:] var _mapInt32AllTypes: Dictionary = [:] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -976,7 +984,15 @@ extension ProtobufUnittest_TestArenaMap: SwiftProtobuf.Message, SwiftProtobuf._M var _mapInt32Enum: Dictionary = [:] var _mapInt32ForeignMessage: Dictionary = [:] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/test_messages_proto2.pb.swift b/Reference/upstream/google/protobuf/test_messages_proto2.pb.swift index 60c7b15cd..ca1dfd606 100644 --- a/Reference/upstream/google/protobuf/test_messages_proto2.pb.swift +++ b/Reference/upstream/google/protobuf/test_messages_proto2.pb.swift @@ -2446,7 +2446,15 @@ extension ProtobufTestMessages_Proto2_TestAllTypesProto2: SwiftProtobuf.Message, var _fieldName17__: Int32? = nil var _fieldName18__: Int32? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -3397,7 +3405,15 @@ extension ProtobufTestMessages_Proto2_TestAllTypesProto2.NestedMessage: SwiftPro var _a: Int32? = nil var _corecursive: ProtobufTestMessages_Proto2_TestAllTypesProto2? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -3960,7 +3976,15 @@ extension ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2: SwiftProtobuf. var _defaultString: String? = nil var _defaultBytes: Data? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -4322,7 +4346,15 @@ extension ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2.NestedMessage: var _corecursive: ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2? = nil var _optionalCorecursive: ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/test_messages_proto3.pb.swift b/Reference/upstream/google/protobuf/test_messages_proto3.pb.swift index 8ca649b5e..cdd42a36b 100644 --- a/Reference/upstream/google/protobuf/test_messages_proto3.pb.swift +++ b/Reference/upstream/google/protobuf/test_messages_proto3.pb.swift @@ -1545,7 +1545,15 @@ extension ProtobufTestMessages_Proto3_TestAllTypesProto3: SwiftProtobuf.Message, var _fieldName17__: Int32 = 0 var _fieldName18__: Int32 = 0 - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -2602,7 +2610,15 @@ extension ProtobufTestMessages_Proto3_TestAllTypesProto3.NestedMessage: SwiftPro var _a: Int32 = 0 var _corecursive: ProtobufTestMessages_Proto3_TestAllTypesProto3? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/unittest.pb.swift b/Reference/upstream/google/protobuf/unittest.pb.swift index c4f16d1dd..013a6955b 100644 --- a/Reference/upstream/google/protobuf/unittest.pb.swift +++ b/Reference/upstream/google/protobuf/unittest.pb.swift @@ -11987,7 +11987,15 @@ extension ProtobufUnittest_TestAllTypes: SwiftProtobuf.Message, SwiftProtobuf._M var _defaultCord: String? = nil var _oneofField: ProtobufUnittest_TestAllTypes.OneOf_OneofField? - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -12705,7 +12713,15 @@ extension ProtobufUnittest_NestedTestAllTypes: SwiftProtobuf.Message, SwiftProto var _lazyChild: ProtobufUnittest_NestedTestAllTypes? = nil var _eagerChild: ProtobufUnittest_TestAllTypes? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -12805,7 +12821,15 @@ extension ProtobufUnittest_TestDeprecatedFields: SwiftProtobuf.Message, SwiftPro var _oneofFields: ProtobufUnittest_TestDeprecatedFields.OneOf_OneofFields? var _nested: ProtobufUnittest_TestDeprecatedFields? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -13903,7 +13927,15 @@ extension ProtobufUnittest_TestRequired: SwiftProtobuf.Message, SwiftProtobuf._M var _c: Int32? = nil var _optionalForeign: ProtobufUnittest_ForeignMessage? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -14306,7 +14338,15 @@ extension ProtobufUnittest_TestNestedRequiredForeign: SwiftProtobuf.Message, Swi var _requiredEnumMulti: ProtobufUnittest_TestRequiredEnumMulti? = nil var _requiredNoMask: ProtobufUnittest_TestRequiredNoMaskMulti? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -14670,7 +14710,15 @@ extension ProtobufUnittest_TestRecursiveMessage: SwiftProtobuf.Message, SwiftPro var _a: ProtobufUnittest_TestRecursiveMessage? = nil var _i: Int32? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -14748,7 +14796,15 @@ extension ProtobufUnittest_TestMutualRecursionA: SwiftProtobuf.Message, SwiftPro var _subGroup: ProtobufUnittest_TestMutualRecursionA.SubGroup? = nil var _subGroupR: [ProtobufUnittest_TestMutualRecursionA.SubGroupR] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -14828,7 +14884,15 @@ extension ProtobufUnittest_TestMutualRecursionA.SubMessage: SwiftProtobuf.Messag fileprivate class _StorageClass { var _b: ProtobufUnittest_TestMutualRecursionB? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -14898,7 +14962,15 @@ extension ProtobufUnittest_TestMutualRecursionA.SubGroup: SwiftProtobuf.Message, var _subMessage: ProtobufUnittest_TestMutualRecursionA.SubMessage? = nil var _notInThisScc: ProtobufUnittest_TestAllTypes? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -15010,7 +15082,15 @@ extension ProtobufUnittest_TestMutualRecursionB: SwiftProtobuf.Message, SwiftPro var _a: ProtobufUnittest_TestMutualRecursionA? = nil var _optionalInt32: Int32? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -15957,7 +16037,15 @@ extension ProtobufUnittest_TestExtremeDefaultValues: SwiftProtobuf.Message, Swif var _cordWithZero: String? = nil var _replacementString: String? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -16415,7 +16503,15 @@ extension ProtobufUnittest_ManyOptionalString: SwiftProtobuf.Message, SwiftProto var _str31: String? = nil var _str32: String? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -20078,7 +20174,15 @@ extension ProtobufUnittest_TestVerifyBigFieldNumberUint32.Nested: SwiftProtobuf. var _optionalNested: ProtobufUnittest_TestVerifyBigFieldNumberUint32.Nested? = nil var _repeatedNested: [ProtobufUnittest_TestVerifyBigFieldNumberUint32.Nested] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -20272,7 +20376,15 @@ extension ProtobufUnittest_EnumParseTester: SwiftProtobuf.Message, SwiftProtobuf var _packedArbitraryHifield: [ProtobufUnittest_EnumParseTester.Arbitrary] = [] var _otherField: Int32? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -20935,7 +21047,15 @@ extension ProtobufUnittest_InlinedStringIdxRegressionProto: SwiftProtobuf.Messag var _str2: String? = nil var _str3: Data? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -21497,7 +21617,15 @@ extension ProtobufUnittest_TestMessageWithManyRepeatedPtrFields: SwiftProtobuf.M var _repeatedString31: [String] = [] var _repeatedString32: [String] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/unittest_custom_options.pb.swift b/Reference/upstream/google/protobuf/unittest_custom_options.pb.swift index c484bde4b..a3aa777cc 100644 --- a/Reference/upstream/google/protobuf/unittest_custom_options.pb.swift +++ b/Reference/upstream/google/protobuf/unittest_custom_options.pb.swift @@ -2585,7 +2585,15 @@ extension ProtobufUnittest_Aggregate: SwiftProtobuf.Message, SwiftProtobuf._Mess var _mset: ProtobufUnittest_AggregateMessageSet? = nil var _any: SwiftProtobuf.Google_Protobuf_Any? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/unittest_enormous_descriptor.pb.swift b/Reference/upstream/google/protobuf/unittest_enormous_descriptor.pb.swift index 3ed8e45eb..96c269a24 100644 --- a/Reference/upstream/google/protobuf/unittest_enormous_descriptor.pb.swift +++ b/Reference/upstream/google/protobuf/unittest_enormous_descriptor.pb.swift @@ -11064,7 +11064,15 @@ extension ProtobufUnittest_TestEnormousDescriptor: SwiftProtobuf.Message, SwiftP var _longFieldNameIsLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong999: String? = nil var _longFieldNameIsLooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong1000: String? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/unittest_features.pb.swift b/Reference/upstream/google/protobuf/unittest_features.pb.swift index 258008af7..9c938e78c 100644 --- a/Reference/upstream/google/protobuf/unittest_features.pb.swift +++ b/Reference/upstream/google/protobuf/unittest_features.pb.swift @@ -486,7 +486,15 @@ extension Pb_TestFeatures: SwiftProtobuf.Message, SwiftProtobuf._MessageImplemen var _intSourceFeature: Int32? = nil var _stringSourceFeature: String? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/unittest_lite.pb.swift b/Reference/upstream/google/protobuf/unittest_lite.pb.swift index 49d377730..49e1b630a 100644 --- a/Reference/upstream/google/protobuf/unittest_lite.pb.swift +++ b/Reference/upstream/google/protobuf/unittest_lite.pb.swift @@ -4120,7 +4120,15 @@ extension ProtobufUnittest_TestAllTypesLite: SwiftProtobuf.Message, SwiftProtobu var _oneofField: ProtobufUnittest_TestAllTypesLite.OneOf_OneofField? var _deceptivelyNamedList: Int32? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -5176,7 +5184,15 @@ extension ProtobufUnittest_TestDeprecatedLite: SwiftProtobuf.Message, SwiftProto var _deprecatedField3: String? = nil var _deprecatedField4: ProtobufUnittest_TestDeprecatedLite? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -6269,7 +6285,15 @@ extension ProtobufUnittest_RecursiveMessage: SwiftProtobuf.Message, SwiftProtobu var _recurse: ProtobufUnittest_RecursiveMessage? = nil var _payload: Data? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/unittest_mset.pb.swift b/Reference/upstream/google/protobuf/unittest_mset.pb.swift index f795cf24c..8f30e5202 100644 --- a/Reference/upstream/google/protobuf/unittest_mset.pb.swift +++ b/Reference/upstream/google/protobuf/unittest_mset.pb.swift @@ -440,7 +440,15 @@ extension ProtobufUnittest_NestedTestMessageSetContainer: SwiftProtobuf.Message, var _child: ProtobufUnittest_NestedTestMessageSetContainer? = nil var _lazyChild: ProtobufUnittest_NestedTestMessageSetContainer? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -533,7 +541,15 @@ extension ProtobufUnittest_NestedTestInt: SwiftProtobuf.Message, SwiftProtobuf._ var _b: Int32? = nil var _child: ProtobufUnittest_NestedTestInt? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/unittest_no_field_presence.pb.swift b/Reference/upstream/google/protobuf/unittest_no_field_presence.pb.swift index 66bab95b2..806907bf9 100644 --- a/Reference/upstream/google/protobuf/unittest_no_field_presence.pb.swift +++ b/Reference/upstream/google/protobuf/unittest_no_field_presence.pb.swift @@ -652,7 +652,15 @@ extension Proto2NofieldpresenceUnittest_TestAllTypes: SwiftProtobuf.Message, Swi var _repeatedLazyMessage: [Proto2NofieldpresenceUnittest_TestAllTypes.NestedMessage] = [] var _oneofField: Proto2NofieldpresenceUnittest_TestAllTypes.OneOf_OneofField? - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/unittest_proto3.pb.swift b/Reference/upstream/google/protobuf/unittest_proto3.pb.swift index 84c228e85..4205cd6d9 100644 --- a/Reference/upstream/google/protobuf/unittest_proto3.pb.swift +++ b/Reference/upstream/google/protobuf/unittest_proto3.pb.swift @@ -881,7 +881,15 @@ extension Proto3Unittest_TestAllTypes: SwiftProtobuf.Message, SwiftProtobuf._Mes var _repeatedLazyMessage: [Proto3Unittest_TestAllTypes.NestedMessage] = [] var _oneofField: Proto3Unittest_TestAllTypes.OneOf_OneofField? - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1559,7 +1567,15 @@ extension Proto3Unittest_NestedTestAllTypes: SwiftProtobuf.Message, SwiftProtobu var _child: Proto3Unittest_NestedTestAllTypes? = nil var _payload: Proto3Unittest_TestAllTypes? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/unittest_proto3_arena.pb.swift b/Reference/upstream/google/protobuf/unittest_proto3_arena.pb.swift index ad1419b89..d6148560a 100644 --- a/Reference/upstream/google/protobuf/unittest_proto3_arena.pb.swift +++ b/Reference/upstream/google/protobuf/unittest_proto3_arena.pb.swift @@ -992,7 +992,15 @@ extension Proto3ArenaUnittest_TestAllTypes: SwiftProtobuf.Message, SwiftProtobuf var _repeatedLazyMessage: [Proto3ArenaUnittest_TestAllTypes.NestedMessage] = [] var _oneofField: Proto3ArenaUnittest_TestAllTypes.OneOf_OneofField? - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1764,7 +1772,15 @@ extension Proto3ArenaUnittest_NestedTestAllTypes: SwiftProtobuf.Message, SwiftPr var _repeatedChild: [Proto3ArenaUnittest_NestedTestAllTypes] = [] var _lazyPayload: Proto3ArenaUnittest_TestAllTypes? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/unittest_proto3_arena_lite.pb.swift b/Reference/upstream/google/protobuf/unittest_proto3_arena_lite.pb.swift index ba0cc534d..68c7679d0 100644 --- a/Reference/upstream/google/protobuf/unittest_proto3_arena_lite.pb.swift +++ b/Reference/upstream/google/protobuf/unittest_proto3_arena_lite.pb.swift @@ -752,7 +752,15 @@ extension Proto3ArenaLiteUnittest_TestAllTypes: SwiftProtobuf.Message, SwiftProt var _repeatedLazyMessage: [Proto3ArenaLiteUnittest_TestAllTypes.NestedMessage] = [] var _oneofField: Proto3ArenaLiteUnittest_TestAllTypes.OneOf_OneofField? - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1418,7 +1426,15 @@ extension Proto3ArenaLiteUnittest_NestedTestAllTypes: SwiftProtobuf.Message, Swi var _child: Proto3ArenaLiteUnittest_NestedTestAllTypes? = nil var _payload: Proto3ArenaLiteUnittest_TestAllTypes? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/unittest_proto3_lite.pb.swift b/Reference/upstream/google/protobuf/unittest_proto3_lite.pb.swift index 62f73809b..c06b7459e 100644 --- a/Reference/upstream/google/protobuf/unittest_proto3_lite.pb.swift +++ b/Reference/upstream/google/protobuf/unittest_proto3_lite.pb.swift @@ -752,7 +752,15 @@ extension Proto3LiteUnittest_TestAllTypes: SwiftProtobuf.Message, SwiftProtobuf. var _repeatedLazyMessage: [Proto3LiteUnittest_TestAllTypes.NestedMessage] = [] var _oneofField: Proto3LiteUnittest_TestAllTypes.OneOf_OneofField? - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1418,7 +1426,15 @@ extension Proto3LiteUnittest_NestedTestAllTypes: SwiftProtobuf.Message, SwiftPro var _child: Proto3LiteUnittest_NestedTestAllTypes? = nil var _payload: Proto3LiteUnittest_TestAllTypes? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/unittest_proto3_optional.pb.swift b/Reference/upstream/google/protobuf/unittest_proto3_optional.pb.swift index b25a99dbc..8cd1e65a8 100644 --- a/Reference/upstream/google/protobuf/unittest_proto3_optional.pb.swift +++ b/Reference/upstream/google/protobuf/unittest_proto3_optional.pb.swift @@ -487,7 +487,15 @@ extension ProtobufUnittest_TestProto3Optional: SwiftProtobuf.Message, SwiftProto var _singularInt32: Int32 = 0 var _singularInt64: Int64 = 0 - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Reference/upstream/google/protobuf/unittest_well_known_types.pb.swift b/Reference/upstream/google/protobuf/unittest_well_known_types.pb.swift index cabb1dd8f..154b54836 100644 --- a/Reference/upstream/google/protobuf/unittest_well_known_types.pb.swift +++ b/Reference/upstream/google/protobuf/unittest_well_known_types.pb.swift @@ -740,7 +740,15 @@ extension ProtobufUnittest_TestWellKnownTypes: SwiftProtobuf.Message, SwiftProto var _bytesField: SwiftProtobuf.Google_Protobuf_BytesValue? = nil var _valueField: SwiftProtobuf.Google_Protobuf_Value? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -950,7 +958,15 @@ extension ProtobufUnittest_RepeatedWellKnownTypes: SwiftProtobuf.Message, SwiftP var _stringField: [SwiftProtobuf.Google_Protobuf_StringValue] = [] var _bytesField: [SwiftProtobuf.Google_Protobuf_BytesValue] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1508,7 +1524,15 @@ extension ProtobufUnittest_MapWellKnownTypes: SwiftProtobuf.Message, SwiftProtob var _stringField: Dictionary = [:] var _bytesField: Dictionary = [:] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Sources/Conformance/test_messages_proto2.pb.swift b/Sources/Conformance/test_messages_proto2.pb.swift index 60c7b15cd..ca1dfd606 100644 --- a/Sources/Conformance/test_messages_proto2.pb.swift +++ b/Sources/Conformance/test_messages_proto2.pb.swift @@ -2446,7 +2446,15 @@ extension ProtobufTestMessages_Proto2_TestAllTypesProto2: SwiftProtobuf.Message, var _fieldName17__: Int32? = nil var _fieldName18__: Int32? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -3397,7 +3405,15 @@ extension ProtobufTestMessages_Proto2_TestAllTypesProto2.NestedMessage: SwiftPro var _a: Int32? = nil var _corecursive: ProtobufTestMessages_Proto2_TestAllTypesProto2? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -3960,7 +3976,15 @@ extension ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2: SwiftProtobuf. var _defaultString: String? = nil var _defaultBytes: Data? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -4322,7 +4346,15 @@ extension ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2.NestedMessage: var _corecursive: ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2? = nil var _optionalCorecursive: ProtobufTestMessages_Proto2_TestAllRequiredTypesProto2? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Sources/Conformance/test_messages_proto3.pb.swift b/Sources/Conformance/test_messages_proto3.pb.swift index 8ca649b5e..cdd42a36b 100644 --- a/Sources/Conformance/test_messages_proto3.pb.swift +++ b/Sources/Conformance/test_messages_proto3.pb.swift @@ -1545,7 +1545,15 @@ extension ProtobufTestMessages_Proto3_TestAllTypesProto3: SwiftProtobuf.Message, var _fieldName17__: Int32 = 0 var _fieldName18__: Int32 = 0 - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -2602,7 +2610,15 @@ extension ProtobufTestMessages_Proto3_TestAllTypesProto3.NestedMessage: SwiftPro var _a: Int32 = 0 var _corecursive: ProtobufTestMessages_Proto3_TestAllTypesProto3? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Sources/SwiftProtobuf/descriptor.pb.swift b/Sources/SwiftProtobuf/descriptor.pb.swift index f62fd02c3..fa94dc25a 100644 --- a/Sources/SwiftProtobuf/descriptor.pb.swift +++ b/Sources/SwiftProtobuf/descriptor.pb.swift @@ -3261,7 +3261,15 @@ extension Google_Protobuf_DescriptorProto: SwiftProtobuf.Message, SwiftProtobuf. var _reservedRange: [Google_Protobuf_DescriptorProto.ReservedRange] = [] var _reservedName: [String] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -4128,7 +4136,15 @@ extension Google_Protobuf_FileOptions: SwiftProtobuf.Message, SwiftProtobuf._Mes var _features: Google_Protobuf_FeatureSet? = nil var _uninterpretedOption: [Google_Protobuf_UninterpretedOption] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -4444,7 +4460,15 @@ extension Google_Protobuf_FieldOptions: SwiftProtobuf.Message, SwiftProtobuf._Me var _features: Google_Protobuf_FeatureSet? = nil var _uninterpretedOption: [Google_Protobuf_UninterpretedOption] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/fuzz_testing.pb.swift b/Tests/SwiftProtobufTests/fuzz_testing.pb.swift index 992e746d6..0e298a49d 100644 --- a/Tests/SwiftProtobufTests/fuzz_testing.pb.swift +++ b/Tests/SwiftProtobufTests/fuzz_testing.pb.swift @@ -3551,7 +3551,15 @@ extension Fuzz_Testing_Message: SwiftProtobuf.Message, SwiftProtobuf._MessageImp var _singularMessageSet: Fuzz_Testing_AMessageSetMessage? = nil var _repeatedMessageSet: [Fuzz_Testing_AMessageSetMessage] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/generated_swift_names_fields.pb.swift b/Tests/SwiftProtobufTests/generated_swift_names_fields.pb.swift index 09a4d1732..c05eb99f4 100644 --- a/Tests/SwiftProtobufTests/generated_swift_names_fields.pb.swift +++ b/Tests/SwiftProtobufTests/generated_swift_names_fields.pb.swift @@ -6666,7 +6666,15 @@ extension ProtobufUnittestGenerated_GeneratedSwiftReservedFields: SwiftProtobuf. var _written: Int32 = 0 var _yday: Int32 = 0 - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/map_unittest.pb.swift b/Tests/SwiftProtobufTests/map_unittest.pb.swift index e1fb0db41..6629a6d7d 100644 --- a/Tests/SwiftProtobufTests/map_unittest.pb.swift +++ b/Tests/SwiftProtobufTests/map_unittest.pb.swift @@ -291,7 +291,15 @@ extension ProtobufUnittest_TestMap: SwiftProtobuf.Message, SwiftProtobuf._Messag var _mapStringForeignMessage: Dictionary = [:] var _mapInt32AllTypes: Dictionary = [:] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/test_messages_proto3.pb.swift b/Tests/SwiftProtobufTests/test_messages_proto3.pb.swift index 2b2aa9a40..5bbc7155c 100644 --- a/Tests/SwiftProtobufTests/test_messages_proto3.pb.swift +++ b/Tests/SwiftProtobufTests/test_messages_proto3.pb.swift @@ -1100,7 +1100,15 @@ extension ProtobufTestMessages_Proto3_TestAllTypesProto3: SwiftProtobuf.Message, var _fieldName17__: Int32 = 0 var _fieldName18__: Int32 = 0 - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1909,7 +1917,15 @@ extension ProtobufTestMessages_Proto3_TestAllTypesProto3.NestedMessage: SwiftPro var _a: Int32 = 0 var _corecursive: ProtobufTestMessages_Proto3_TestAllTypesProto3? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/unittest.pb.swift b/Tests/SwiftProtobufTests/unittest.pb.swift index 2fe7aed13..a112531a4 100644 --- a/Tests/SwiftProtobufTests/unittest.pb.swift +++ b/Tests/SwiftProtobufTests/unittest.pb.swift @@ -4681,7 +4681,15 @@ extension ProtobufUnittest_TestAllTypes: SwiftProtobuf.Message, SwiftProtobuf._M var _defaultCord: String? = nil var _oneofField: ProtobufUnittest_TestAllTypes.OneOf_OneofField? - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -5358,7 +5366,15 @@ extension ProtobufUnittest_NestedTestAllTypes: SwiftProtobuf.Message, SwiftProto var _lazyChild: ProtobufUnittest_NestedTestAllTypes? = nil var _eagerChild: ProtobufUnittest_TestAllTypes? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -5678,7 +5694,15 @@ extension ProtobufUnittest_TestRequired: SwiftProtobuf.Message, SwiftProtobuf._M var _c: Int32? = nil var _optionalForeign: ProtobufUnittest_ForeignMessage? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -6132,7 +6156,15 @@ extension ProtobufUnittest_TestRecursiveMessage: SwiftProtobuf.Message, SwiftPro var _a: ProtobufUnittest_TestRecursiveMessage? = nil var _i: Int32? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -6364,7 +6396,15 @@ extension ProtobufUnittest_TestExtremeDefaultValues: SwiftProtobuf.Message, Swif var _cordWithZero: String? = nil var _replacementString: String? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/unittest_proto3.pb.swift b/Tests/SwiftProtobufTests/unittest_proto3.pb.swift index a6000df4c..14a67e159 100644 --- a/Tests/SwiftProtobufTests/unittest_proto3.pb.swift +++ b/Tests/SwiftProtobufTests/unittest_proto3.pb.swift @@ -820,7 +820,15 @@ extension Proto3Unittest_TestAllTypes: SwiftProtobuf.Message, SwiftProtobuf._Mes var _repeatedLazyMessage: [Proto3Unittest_TestAllTypes.NestedMessage] = [] var _oneofField: Proto3Unittest_TestAllTypes.OneOf_OneofField? - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1498,7 +1506,15 @@ extension Proto3Unittest_NestedTestAllTypes: SwiftProtobuf.Message, SwiftProtobu var _child: Proto3Unittest_NestedTestAllTypes? = nil var _payload: Proto3Unittest_TestAllTypes? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/unittest_proto3_optional.pb.swift b/Tests/SwiftProtobufTests/unittest_proto3_optional.pb.swift index b949a4ed1..199d35607 100644 --- a/Tests/SwiftProtobufTests/unittest_proto3_optional.pb.swift +++ b/Tests/SwiftProtobufTests/unittest_proto3_optional.pb.swift @@ -382,7 +382,15 @@ extension ProtobufUnittest_TestProto3Optional: SwiftProtobuf.Message, SwiftProto var _singularInt32: Int32 = 0 var _singularInt64: Int64 = 0 - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/unittest_swift_all_required_types.pb.swift b/Tests/SwiftProtobufTests/unittest_swift_all_required_types.pb.swift index 8100bd2ad..dd0c1e6b4 100644 --- a/Tests/SwiftProtobufTests/unittest_swift_all_required_types.pb.swift +++ b/Tests/SwiftProtobufTests/unittest_swift_all_required_types.pb.swift @@ -867,7 +867,15 @@ extension ProtobufUnittest_TestAllRequiredTypes: SwiftProtobuf.Message, SwiftPro var _defaultCord: String? = nil var _oneofField: ProtobufUnittest_TestAllRequiredTypes.OneOf_OneofField? - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/unittest_swift_cycle.pb.swift b/Tests/SwiftProtobufTests/unittest_swift_cycle.pb.swift index 87145ef2b..76049b987 100644 --- a/Tests/SwiftProtobufTests/unittest_swift_cycle.pb.swift +++ b/Tests/SwiftProtobufTests/unittest_swift_cycle.pb.swift @@ -189,7 +189,15 @@ extension ProtobufUnittest_CycleFoo: SwiftProtobuf.Message, SwiftProtobuf._Messa var _aBar: ProtobufUnittest_CycleBar? = nil var _aBaz: ProtobufUnittest_CycleBaz? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -273,7 +281,15 @@ extension ProtobufUnittest_CycleBar: SwiftProtobuf.Message, SwiftProtobuf._Messa var _aBaz: ProtobufUnittest_CycleBaz? = nil var _aFoo: ProtobufUnittest_CycleFoo? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -357,7 +373,15 @@ extension ProtobufUnittest_CycleBaz: SwiftProtobuf.Message, SwiftProtobuf._Messa var _aFoo: ProtobufUnittest_CycleFoo? = nil var _aBar: ProtobufUnittest_CycleBar? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/unittest_swift_enum_optional_default.pb.swift b/Tests/SwiftProtobufTests/unittest_swift_enum_optional_default.pb.swift index b731aa90c..e2678cf04 100644 --- a/Tests/SwiftProtobufTests/unittest_swift_enum_optional_default.pb.swift +++ b/Tests/SwiftProtobufTests/unittest_swift_enum_optional_default.pb.swift @@ -199,7 +199,15 @@ extension ProtobufUnittest_Extend_EnumOptionalDefault.NestedMessage: SwiftProtob var _message: ProtobufUnittest_Extend_EnumOptionalDefault.NestedMessage? = nil var _optionalEnum: ProtobufUnittest_Extend_EnumOptionalDefault.NestedMessage.Enum? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/unittest_swift_extension.pb.swift b/Tests/SwiftProtobufTests/unittest_swift_extension.pb.swift index 3783af78a..606f730c5 100644 --- a/Tests/SwiftProtobufTests/unittest_swift_extension.pb.swift +++ b/Tests/SwiftProtobufTests/unittest_swift_extension.pb.swift @@ -653,7 +653,15 @@ extension ProtobufUnittest_Extend_MsgUsesStorage: SwiftProtobuf.Message, SwiftPr var _x: Int32? = nil var _y: ProtobufUnittest_Extend_MsgUsesStorage? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/unittest_swift_naming.pb.swift b/Tests/SwiftProtobufTests/unittest_swift_naming.pb.swift index 7917b9a9f..72d7b1c28 100644 --- a/Tests/SwiftProtobufTests/unittest_swift_naming.pb.swift +++ b/Tests/SwiftProtobufTests/unittest_swift_naming.pb.swift @@ -17216,7 +17216,15 @@ extension SwiftUnittest_Names_FieldNames: SwiftProtobuf.Message, SwiftProtobuf._ var _extension: Int32? = nil var _extensions: Int32? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -27669,7 +27677,15 @@ extension SwiftUnittest_Names_FieldNamingInitials.Lowers: SwiftProtobuf.Message, var _theIDNumber: Int32? = nil var _requestID: Int32? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -28432,7 +28448,15 @@ extension SwiftUnittest_Names_SpecialNames3: SwiftProtobuf.Message, SwiftProtobu var _newValue: SwiftUnittest_Names_SpecialNames3.OneOf_NewValue? var _forcesStorage: SwiftUnittest_Names_SpecialNames3? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -28515,7 +28539,15 @@ extension SwiftUnittest_Names_SpecialNames4: SwiftProtobuf.Message, SwiftProtobu var _newValue: String? = nil var _forcesStorage: SwiftUnittest_Names_SpecialNames4? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/unittest_swift_runtime_proto2.pb.swift b/Tests/SwiftProtobufTests/unittest_swift_runtime_proto2.pb.swift index ec106e899..e007c9f1b 100644 --- a/Tests/SwiftProtobufTests/unittest_swift_runtime_proto2.pb.swift +++ b/Tests/SwiftProtobufTests/unittest_swift_runtime_proto2.pb.swift @@ -1045,7 +1045,15 @@ extension ProtobufUnittest_Message2: SwiftProtobuf.Message, SwiftProtobuf._Messa var _mapInt32Enum: Dictionary = [:] var _mapInt32Message: Dictionary = [:] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1810,7 +1818,15 @@ extension ProtobufUnittest_Msg2UsesStorage: SwiftProtobuf.Message, SwiftProtobuf fileprivate class _StorageClass { var _y: ProtobufUnittest_Msg2UsesStorage? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/unittest_swift_runtime_proto3.pb.swift b/Tests/SwiftProtobufTests/unittest_swift_runtime_proto3.pb.swift index 8589ebd19..a9202e65a 100644 --- a/Tests/SwiftProtobufTests/unittest_swift_runtime_proto3.pb.swift +++ b/Tests/SwiftProtobufTests/unittest_swift_runtime_proto3.pb.swift @@ -844,7 +844,15 @@ extension ProtobufUnittest_Message3: SwiftProtobuf.Message, SwiftProtobuf._Messa var _mapInt32Enum: Dictionary = [:] var _mapInt32Message: Dictionary = [:] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1466,7 +1474,15 @@ extension ProtobufUnittest_Msg3UsesStorage: SwiftProtobuf.Message, SwiftProtobuf fileprivate class _StorageClass { var _y: ProtobufUnittest_Msg3UsesStorage? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} diff --git a/Tests/SwiftProtobufTests/unittest_well_known_types.pb.swift b/Tests/SwiftProtobufTests/unittest_well_known_types.pb.swift index bce16661e..f8671c1b4 100644 --- a/Tests/SwiftProtobufTests/unittest_well_known_types.pb.swift +++ b/Tests/SwiftProtobufTests/unittest_well_known_types.pb.swift @@ -763,7 +763,15 @@ extension ProtobufUnittest_TestWellKnownTypes: SwiftProtobuf.Message, SwiftProto var _bytesField: SwiftProtobuf.Google_Protobuf_BytesValue? = nil var _valueField: SwiftProtobuf.Google_Protobuf_Value? = nil - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -973,7 +981,15 @@ extension ProtobufUnittest_RepeatedWellKnownTypes: SwiftProtobuf.Message, SwiftP var _stringField: [SwiftProtobuf.Google_Protobuf_StringValue] = [] var _bytesField: [SwiftProtobuf.Google_Protobuf_BytesValue] = [] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} @@ -1531,7 +1547,15 @@ extension ProtobufUnittest_MapWellKnownTypes: SwiftProtobuf.Message, SwiftProtob var _stringField: Dictionary = [:] var _bytesField: Dictionary = [:] - static let defaultInstance = _StorageClass() + #if swift(>=5.10) + // This property is used as the initial default value for new instances of the type. + // The type itself is protecting the reference to its storage via CoW semantics. + // This will force a copy to be made of this reference when the first mutation occurs; + // hence, it is safe to mark this as `nonisolated(unsafe)`. + static nonisolated(unsafe) let defaultInstance = _StorageClass() + #else + static let defaultInstance = _StorageClass() + #endif private init() {} From 627d77b17d4ce6064d4389bd79aeef78d2246257 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Fri, 15 Mar 2024 10:23:52 -0400 Subject: [PATCH 3/3] 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 | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Sources/SwiftProtobuf/NameMap.swift b/Sources/SwiftProtobuf/NameMap.swift index f2822e893..eb948894b 100644 --- a/Sources/SwiftProtobuf/NameMap.swift +++ b/Sources/SwiftProtobuf/NameMap.swift @@ -308,3 +308,18 @@ public struct _NameMap: ExpressibleByDictionaryLiteral { return jsonToNumberMap[n] } } + +#if swift(>=5.5) && canImport(_Concurrency) +// 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 {} +#endif