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

fix: Supply explicit type on forEach block to try preventing compiler crash #801

Merged
merged 3 commits into from
Aug 15, 2024

Conversation

jbelkins
Copy link
Contributor

Issue #

awslabs/aws-sdk-swift#1681

Description of changes

Preview builds are failing (on a compiler crash) while type checking the expression:

        config.httpInterceptorProviders.forEach { provider in
            let i: any ClientRuntime.HttpInterceptor<ListApplicationInstancesInput, ListApplicationInstancesOutput> = provider.create()
            builder.interceptors.add(i)
        }

This PR adds explicit type info to the forEach body, attempting to aid in type checking:

        config.httpInterceptorProviders.forEach { (provider: any ClientRuntime.HttpInterceptorProvider) -> Void in
            let i: any ClientRuntime.HttpInterceptor<ListApplicationInstancesInput, ListApplicationInstancesOutput> = provider.create()
            builder.interceptors.add(i)
        }

Scope

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@jbelkins jbelkins requested review from dayaffe and sichanyoo August 15, 2024 21:01
@@ -58,18 +58,18 @@ class MiddlewareExecutionGenerator(
}
""".trimIndent()
)
// Swift can't infer the generic arguments to `create` for some reason
Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol Swift can't infer the generic arguments to create because it has nothing to infer from, unless you explicitly give a type for the variable the return value will be assigned to.

outputShape,
)
writer.openBlock(
"config.httpInterceptorProviders.forEach { (provider: any \$N) -> Void in",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cleaned up the multiline write() call while adding the type info to the forEach body block.

@jbelkins jbelkins merged commit 57e154b into main Aug 15, 2024
27 checks passed
@jbelkins jbelkins deleted the jbe/interceptor_provider_explicit_type branch August 15, 2024 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants