Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For Swift 5.10, mark Message/Enum _protobuf_nameMap nonisolated(unsafe) #1564

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,17 @@ public struct ImportsAPublicly: Sendable {

extension ImportsAPublicly: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = "ImportsAPublicly"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
11: .same(proto: "a"),
12: .same(proto: "e"),
]
#if swift(>=5.10)
public static nonisolated(unsafe) let _protobuf_nameMap: SwiftProtobuf._NameMap = _makeNameMap()
#else
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = _makeNameMap()
#endif
private static func _makeNameMap() -> SwiftProtobuf._NameMap {
return [
11: .same(proto: "a"),
12: .same(proto: "e"),
]
}

public var isInitialized: Bool {
if let v = self._a, !v.isInitialized {return false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,17 @@ public struct ImportsImportsAPublicly: Sendable {

extension ImportsImportsAPublicly: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = "ImportsImportsAPublicly"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
21: .same(proto: "a"),
22: .same(proto: "e"),
]
#if swift(>=5.10)
public static nonisolated(unsafe) let _protobuf_nameMap: SwiftProtobuf._NameMap = _makeNameMap()
#else
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = _makeNameMap()
#endif
private static func _makeNameMap() -> SwiftProtobuf._NameMap {
return [
21: .same(proto: "a"),
22: .same(proto: "e"),
]
}

public var isInitialized: Bool {
if let v = self._a, !v.isInitialized {return false}
Expand Down
30 changes: 22 additions & 8 deletions CompileTests/MultiModule/Sources/ModuleA/a.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,32 @@ public let Extensions_ext_str = SwiftProtobuf.MessageExtension<SwiftProtobuf.Opt
// MARK: - Code below here is support for the SwiftProtobuf runtime.

extension E: SwiftProtobuf._ProtoNameProviding {
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
0: .same(proto: "E_UNSET"),
1: .same(proto: "E_A"),
2: .same(proto: "E_B"),
]
#if swift(>=5.10)
public static nonisolated(unsafe) let _protobuf_nameMap: SwiftProtobuf._NameMap = _makeNameMap()
#else
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = _makeNameMap()
#endif
private static func _makeNameMap() -> SwiftProtobuf._NameMap {
return [
0: .same(proto: "E_UNSET"),
1: .same(proto: "E_A"),
2: .same(proto: "E_B"),
]
}
}

extension A: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = "A"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
1: .same(proto: "e"),
]
#if swift(>=5.10)
public static nonisolated(unsafe) let _protobuf_nameMap: SwiftProtobuf._NameMap = _makeNameMap()
#else
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = _makeNameMap()
#endif
private static func _makeNameMap() -> SwiftProtobuf._NameMap {
return [
1: .same(proto: "e"),
]
}

public var isInitialized: Bool {
if !_protobuf_extensionFieldValues.isInitialized {return false}
Expand Down
15 changes: 11 additions & 4 deletions CompileTests/MultiModule/Tests/Test1/uses_a_transitively.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,17 @@ public struct UsesATransitively: Sendable {

extension UsesATransitively: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = "UsesATransitively"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
101: .same(proto: "a"),
102: .same(proto: "e"),
]
#if swift(>=5.10)
public static nonisolated(unsafe) let _protobuf_nameMap: SwiftProtobuf._NameMap = _makeNameMap()
#else
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = _makeNameMap()
#endif
private static func _makeNameMap() -> SwiftProtobuf._NameMap {
return [
101: .same(proto: "a"),
102: .same(proto: "e"),
]
}

public var isInitialized: Bool {
if let v = self._a, !v.isInitialized {return false}
Expand Down
15 changes: 11 additions & 4 deletions CompileTests/MultiModule/Tests/Test2/uses_a_transitively2.pb.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,17 @@ public struct UsesATransitively2: Sendable {

extension UsesATransitively2: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
public static let protoMessageName: String = "UsesATransitively2"
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
111: .same(proto: "a"),
122: .same(proto: "e"),
]
#if swift(>=5.10)
public static nonisolated(unsafe) let _protobuf_nameMap: SwiftProtobuf._NameMap = _makeNameMap()
#else
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = _makeNameMap()
#endif
private static func _makeNameMap() -> SwiftProtobuf._NameMap {
return [
111: .same(proto: "a"),
122: .same(proto: "e"),
]
}

public var isInitialized: Bool {
if let v = self._a, !v.isInitialized {return false}
Expand Down
Loading
Loading