smithy-lang / smithy-kotlin

Smithy code generator for Kotlin (in development)
Apache License 2.0
76 stars 26 forks source link

fix: `AttributeKey` code generation #1001

Closed lauzadis closed 8 months ago

lauzadis commented 8 months ago

Usage of AttributeKey in endpoints code generation fails with Not enough information to infer type variable T.

Example usage:

return Endpoint(
    Url.parse("${url?.scheme}://${url?.authority}/${uriEncodedBucket}${url?.path}"),
    attributes = attributesOf {
        AttributeKey("backend") to "FOOBAR" // Not enough information to infer type variable T
        SigningContextAttributeKey to listOf(
            sigV4(
                serviceName = "s3",
                disableDoubleUriEncode = true,
                signingRegion = "${params.region}",
            ),
        )
    },
)

The fix is to provide the type for AttributeKey<T>. New codegen will look like:

AttributeKey.create("backend", "FOOBAR") to "FOOBAR"

This is done to avoid type-parsing at codegen and just let the Kotlin compiler work it out.

Issue \

Description of changes

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

sonarcloud[bot] commented 8 months ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication