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

feat: Make models Sendable #1771

Merged
merged 12 commits into from
Sep 24, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import Waiters
import SmithyWaitersAPI

// Convenience test-helper methods for testing acceptor matches

extension WaiterConfiguration.Acceptor.Match: Equatable where Input: Equatable, Output: Equatable {
//
// Use of fully-qualified type names in this extension suppresses the Swift 6
// "retroactive conformance" warning in a manner compatible with Swift 5.
// See: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0364-retroactive-conformance-warning.md#source-compatibility
extension SmithyWaitersAPI.WaiterConfiguration.Acceptor.Match: Swift.Equatable where Input: Swift.Equatable, Output: Swift.Equatable {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using fully-qualified names in an extension declaration suppresses "retroactive conformance" warnings while still being compatible with Swift 5.x (using @retroactive in Swift 5 results in a compile error.)


public static func == (
lhs: WaiterConfiguration<Input, Output>.Acceptor.Match,
Expand Down Expand Up @@ -42,7 +45,11 @@ extension WaiterConfiguration.Acceptor.Match: Equatable where Input: Equatable,
}

// Allows for the use of a string as an Error, for easy test validation & easy-to-read tests.
extension String: Error {
//
// Use of fully-qualified type names in this extension suppresses the Swift 6
// "retroactive conformance" warning in a manner compatible with Swift 5.
// See: https://github.com/swiftlang/swift-evolution/blob/main/proposals/0364-retroactive-conformance-warning.md#source-compatibility
extension Swift.String: Swift.Error {
var localizedString: String? { self }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,21 @@ class S3ExpiresTest {
val context = setupTests("s3-expires.smithy", "com.amazonaws.s3#S3", "S3")
val contents = TestUtils.getFileContents(context.manifest, "Sources/Example/models/FooOutput.swift")
contents.shouldSyntacticSanityCheck()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests fixed below, which were affected by the changes made in smithy-swift.

val expectedContents =
"""
public struct FooOutput {
public var expires: Swift.String?
public var payload1: Swift.String?

public init(
expires: Swift.String? = nil,
payload1: Swift.String? = nil
)
{
self.expires = expires
self.payload1 = payload1
}
}
""".trimIndent()
val expectedContents = """
public struct FooOutput: Swift.Sendable {
public var expires: Swift.String?
public var payload1: Swift.String?

public init(
expires: Swift.String? = nil,
payload1: Swift.String? = nil
)
{
self.expires = expires
self.payload1 = payload1
}
}
"""
contents.shouldContainOnlyOnce(expectedContents)
}

Expand All @@ -39,22 +38,21 @@ class S3ExpiresTest {
val context = setupTests("s3-expires.smithy", "com.amazonaws.s3#S3", "S3")
val contents = TestUtils.getFileContents(context.manifest, "Sources/Example/models/FooInput.swift")
contents.shouldSyntacticSanityCheck()
val expectedContents =
"""
public struct FooInput {
public var expires: Swift.String?
public var payload1: Swift.String?

public init(
expires: Swift.String? = nil,
payload1: Swift.String? = nil
)
{
self.expires = expires
self.payload1 = payload1
}
}
""".trimIndent()
val expectedContents = """
public struct FooInput: Swift.Sendable {
public var expires: Swift.String?
public var payload1: Swift.String?

public init(
expires: Swift.String? = nil,
payload1: Swift.String? = nil
)
{
self.expires = expires
self.payload1 = payload1
}
}
"""
contents.shouldContainOnlyOnce(expectedContents)
}

Expand All @@ -64,7 +62,7 @@ class S3ExpiresTest {
val contents = TestUtils.getFileContents(context.manifest, "Sources/Example/models/FooOutput.swift")
contents.shouldSyntacticSanityCheck()
val expectedContents = """
public struct FooOutput {
public struct FooOutput: Swift.Sendable {
public var expires: Foundation.Date?
public var payload1: Swift.String?

Expand Down
Loading