Skip to content

Commit 1d60201

Browse files
authored
chore(build): fix build warnings for swift 6 experimental features (#4041)
* chore(build): fix build warnings for swift 6 experimental features * chore: add @unchecked Sendable conformances and nonisolated modifiers * chore: fix swiftlint errors * chore: add @preconcurrency attribute for module imports * chore: add more preconcurrency attributes * chore: add preconcurrency to model generated files * chore: fix failing unit test * chore: revert ActivityTracker changes * chore: update EndpointResolving * chore: resolve swiftlint error
1 parent 5866f82 commit 1d60201

File tree

249 files changed

+389
-377
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

249 files changed

+389
-377
lines changed

Amplify/Categories/API/Operation/RetryableGraphQLOperation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public final class RetryableGraphQLOperation<Payload: Decodable> {
7272

7373
}
7474

75-
public final class RetryableGraphQLSubscriptionOperation<Payload: Decodable> {
75+
public final class RetryableGraphQLSubscriptionOperation<Payload> where Payload: Decodable, Payload: Sendable {
7676

7777
public typealias Payload = Payload
7878
public typealias SubscriptionEvents = GraphQLSubscriptionEvent<Payload>

Amplify/Categories/API/Response/GraphQLError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public struct GraphQLError: Decodable {
3535
extension GraphQLError {
3636

3737
/// Both `line` and `column` are positive numbers describing the beginning of an associated syntax element
38-
public struct Location: Decodable {
38+
public struct Location: Decodable, @unchecked Sendable {
3939

4040
/// The line describing the associated syntax element
4141
public let line: Int

Amplify/Categories/API/Response/GraphQLResponse.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public typealias GraphQLResponse<ResponseType: Decodable> =
1515
Result<ResponseType, GraphQLResponseError<ResponseType>>
1616

1717
/// An error response from a GraphQL API
18-
public enum GraphQLResponseError<ResponseType: Decodable>: AmplifyError {
18+
public enum GraphQLResponseError<ResponseType>: AmplifyError where ResponseType: Sendable, ResponseType: Decodable {
1919

2020
/// An error response. The associated value will be an array of GraphQLError objects that contain service-specific
2121
/// error messages. https://graphql.github.io/graphql-spec/June2018/#sec-Errors

Amplify/Categories/DataStore/DataStoreConflict.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77

88
/// Information about a conflict that occurred attempting to sync a local model with a remote model
9-
public struct DataStoreSyncConflict {
9+
public struct DataStoreSyncConflict: @unchecked Sendable {
1010
public let localModel: Model
1111
public let remoteModel: Model
1212
public let errors: [GraphQLError]?

Amplify/Categories/DataStore/Model/Internal/ModelListDecoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Foundation
1515
/// application making any change to these `public` types should be backward compatible, otherwise it will be a breaking
1616
/// change.
1717
public struct ModelListDecoderRegistry {
18-
public static var listDecoders = AtomicValue(initialValue: [ModelListDecoder.Type]())
18+
nonisolated(unsafe) public static var listDecoders = AtomicValue(initialValue: [ModelListDecoder.Type]())
1919

2020
/// Register a decoder during plugin configuration time, to allow runtime retrievals of list providers.
2121
public static func registerDecoder(_ listDecoder: ModelListDecoder.Type) {

Amplify/Categories/DataStore/Model/Internal/ModelProviderDecoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Foundation
1515
/// application making any change to these `public` types should be backward compatible, otherwise it will be a breaking
1616
/// change.
1717
public struct ModelProviderRegistry {
18-
static var decoders = AtomicValue(initialValue: [ModelProviderDecoder.Type]())
18+
nonisolated(unsafe) static var decoders = AtomicValue(initialValue: [ModelProviderDecoder.Type]())
1919

2020
/// Register a decoder during plugin configuration time, to allow runtime retrievals of model providers.
2121
public static func registerDecoder(_ decoder: ModelProviderDecoder.Type) {

Amplify/Categories/DataStore/Model/Internal/ModelRegistry.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ public struct ModelRegistry {
1616
/// ModelDecoders are used to decode untyped model data, looking up by model name
1717
private typealias ModelDecoder = (String, JSONDecoder?) throws -> Model
1818

19-
private static var modelTypes = [ModelName: Model.Type]()
19+
nonisolated(unsafe) private static var modelTypes = [ModelName: Model.Type]()
2020

21-
private static var modelDecoders = [ModelName: ModelDecoder]()
21+
nonisolated(unsafe) private static var modelDecoders = [ModelName: ModelDecoder]()
2222

23-
private static var modelSchemaMapping = [ModelName: ModelSchema]()
23+
nonisolated(unsafe) private static var modelSchemaMapping = [ModelName: ModelSchema]()
2424

2525
public static var models: [Model.Type] {
2626
concurrencyQueue.sync {

Amplify/Categories/DataStore/Model/Internal/Schema/ModelField+Association.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ import Foundation
8686
///
8787
/// - Warning: Although this has `public` access, it is intended for internal & codegen use and should not be used
8888
/// directly by host applications. The behavior of this may change without warning.
89-
public enum ModelAssociation {
89+
public enum ModelAssociation: @unchecked Sendable {
9090
case hasMany(associatedFieldName: String?, associatedFieldNames: [String] = [])
9191
case hasOne(associatedFieldName: String?, associatedFieldNames: [String] = [], targetNames: [String])
9292
case belongsTo(associatedFieldName: String?, targetNames: [String])

Amplify/Categories/DataStore/Model/Temporal/Date+Operation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import Foundation
1717
///
1818
/// let yesterday = Temporal.Date.now() - .days(1)
1919
/// let sixMonthsAgo = Temporal.Date.now() - .months(6)
20-
public struct DateUnit {
20+
public struct DateUnit: @unchecked Sendable {
2121
let calendarComponent: Calendar.Component
2222
let value: Int
2323

Amplify/Categories/DataStore/Model/Temporal/Temporal+Cache.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ extension Temporal {
1212
// of the formatter cache dictionary.
1313
//
1414
// DateFormatter itself is thread safe.
15-
private static var formatterCache: [String: DateFormatter] = [:]
15+
nonisolated(unsafe) private static var formatterCache: [String: DateFormatter] = [:]
1616

1717
@usableFromInline
1818
/// The `Calendar` used for date operations.
@@ -26,7 +26,7 @@ extension Temporal {
2626
}()
2727

2828
/// Pointer to lock to ensure exclusive access.
29-
private static let lock: UnsafeMutablePointer<os_unfair_lock> = {
29+
nonisolated(unsafe) private static let lock: UnsafeMutablePointer<os_unfair_lock> = {
3030
let pointer = UnsafeMutablePointer<os_unfair_lock>.allocate(capacity: 1)
3131
pointer.initialize(to: os_unfair_lock())
3232
return pointer

0 commit comments

Comments
 (0)