Skip to content

Commit

Permalink
Make when expression non exhaustive in EndpointBuiltInsDecorator.kt (#…
Browse files Browse the repository at this point in the history
…3634)

## Motivation and Context
Updates handling matching on endpoint parameter type in
`EndpointBuiltInsDecorator.kt`

## Description
Smithy 1.48.0 will introduce `ParameterType.STRING_ARRAY` for the
endpoint parameter type and exhaustive matching like what we have today
makes lint unhappy.
```
codegen/src/main/kotlin/software/amazon/smithy/rustsdk/EndpointBuiltInsDecorator.kt: (113, 9): 'when' expression must be exhaustive, add necessary 'STRING_ARRAY' branch or 'else' branch instead 
```

For now, we will fail out loud for anything other than `string` or
`boolean` since we most likely don't have services that support
`ParameterType.STRING_ARRAY` today. The panic will let us know during
internal preview when a service supports `ParameterType.STRING_ARRAY`.

## Testing
Relies on tests in CI

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
  • Loading branch information
ysaito1001 authored May 9, 2024
1 parent 1468813 commit 14ccc50
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@ fun Model.sdkConfigSetter(
val builtIn = loadBuiltIn(serviceId, builtInSrc) ?: return null
val fieldName = configParameterNameOverride ?: builtIn.name.rustName()

val builtinType = builtIn.type!!
val map =
when (builtIn.type!!) {
when (builtinType) {
ParameterType.STRING -> writable { rust("|s|s.to_string()") }
ParameterType.BOOLEAN -> null
else -> PANIC("needs to handle unimplemented endpoint parameter builtin type: $builtinType")
}

return if (fieldName == "endpoint_url") {
Expand Down

0 comments on commit 14ccc50

Please sign in to comment.