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

Make the Extension related types Sendable. #1444

Merged
merged 1 commit into from
Sep 25, 2023
Merged
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
4 changes: 1 addition & 3 deletions Sources/SwiftProtobuf/ExtensionFieldValueSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
///
// -----------------------------------------------------------------------------

// TODO: `ExtensionFieldValueSet` should be `Sendable` but we cannot do so yet without possibly breaking compatibility.

public struct ExtensionFieldValueSet: Hashable {
public struct ExtensionFieldValueSet: Hashable, Sendable {
fileprivate var values = [Int : AnyExtensionField]()

public static func ==(lhs: ExtensionFieldValueSet,
Expand Down
6 changes: 2 additions & 4 deletions Sources/SwiftProtobuf/ExtensionFields.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
///
// -----------------------------------------------------------------------------

// TODO: `AnyExtensionField` should require `Sendable` but we cannot do so yet without possibly breaking compatibility.

//
// Type-erased Extension field implementation.
// Note that it has no "self or associated type" references, so can
Expand All @@ -24,7 +22,7 @@
// equality with some other extension field; but it's type-sealed
// so you can't actually access the contained value itself.
//
public protocol AnyExtensionField {
public protocol AnyExtensionField: Sendable {
func hash(into hasher: inout Hasher)
var protobufExtension: AnyMessageExtension { get }
func isEqual(other: AnyExtensionField) -> Bool
Expand All @@ -48,7 +46,7 @@ extension AnyExtensionField {
///
/// The regular ExtensionField type exposes the value directly.
///
public protocol ExtensionField: AnyExtensionField, Hashable {
public protocol ExtensionField: AnyExtensionField, Hashable, Sendable {
associatedtype ValueType
var value: ValueType { get set }
init(protobufExtension: AnyMessageExtension, value: ValueType)
Expand Down
6 changes: 2 additions & 4 deletions Sources/SwiftProtobuf/FieldTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@

import Foundation

// TODO: `FieldType` and `FieldType.BaseType` should require `Sendable` but we cannot do so yet without possibly breaking compatibility.

// Note: The protobuf- and JSON-specific methods here are defined
// in ProtobufTypeAdditions.swift and JSONTypeAdditions.swift
public protocol FieldType {
public protocol FieldType: Sendable {
// The Swift type used to store data for this field. For example,
// proto "sint32" fields use Swift "Int32" type.
associatedtype BaseType: Hashable
associatedtype BaseType: Hashable, Sendable

// The default value for this field type before it has been set.
// This is also used, for example, when JSON decodes a "null"
Expand Down