Skip to content

Commit

Permalink
fix: Supply explicit type on forEach block to try preventing compil…
Browse files Browse the repository at this point in the history
…er crash (#801)
  • Loading branch information
jbelkins committed Aug 15, 2024
1 parent 5cfec7b commit 57e154b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,19 @@ class MiddlewareExecutionGenerator(
}
""".trimIndent()
)
// Swift can't infer the generic arguments to `create` for some reason
writer.write(
"""
config.httpInterceptorProviders.forEach { provider in
let i: any ${'$'}N<${'$'}N, ${'$'}N> = provider.create()
builder.interceptors.add(i)
}
""".trimIndent(),
ClientRuntimeTypes.Core.HttpInterceptor,
inputShape,
outputShape,
)
writer.openBlock(
"config.httpInterceptorProviders.forEach { (provider: any \$N) -> Void in",
"}",
ClientRuntimeTypes.Core.HttpInterceptorProvider,
) {
writer.write(
"let i: any \$N<\$N, \$N> = provider.create()",
ClientRuntimeTypes.Core.HttpInterceptor,
inputShape,
outputShape,
)
writer.write("builder.interceptors.add(i)")
}

renderMiddlewares(ctx, op, operationStackName)

Expand Down
2 changes: 1 addition & 1 deletion smithy-swift-codegen/src/test/kotlin/EventStreamTests.kt
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ extension EventStreamTestClientTypes.TestStream {
config.interceptorProviders.forEach { provider in
builder.interceptors.add(provider.create())
}
config.httpInterceptorProviders.forEach { provider in
config.httpInterceptorProviders.forEach { (provider: any ClientRuntime.HttpInterceptorProvider) -> Void in
let i: any ClientRuntime.HttpInterceptor<TestStreamOpInput, TestStreamOpOutput> = provider.create()
builder.interceptors.add(i)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ extension RestJsonProtocolClient {
config.interceptorProviders.forEach { provider in
builder.interceptors.add(provider.create())
}
config.httpInterceptorProviders.forEach { provider in
config.httpInterceptorProviders.forEach { (provider: any ClientRuntime.HttpInterceptorProvider) -> Void in
let i: any ClientRuntime.HttpInterceptor<AllocateWidgetInput, AllocateWidgetOutput> = provider.create()
builder.interceptors.add(i)
}
Expand Down

0 comments on commit 57e154b

Please sign in to comment.