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

Codegen doesn't properly handle unions with a member that has the same name as the union #1129

Open
ianbotsf opened this issue Jul 25, 2024 · 0 comments
Labels
bug This issue is a bug.

Comments

@ianbotsf
Copy link
Contributor

Describe the bug

Given a model:

union Foo {
    foo: Boolean
}

The generated union code does not take into account the shadowed name:

public sealed class Foo {
    public data class Foo(val value: Boolean)

    public fun asFoo(): Boolean = (this as Foo.Foo).value // Compilation error: `Foo` (the data class) has no member `Foo`
}

The problem is likely in UnionGenerator's handling of symbols.

Expected behavior

Code should be generated correctly for a union that has a member of the same name

Current behavior

Code is generated incorrectly and fails to compile

Steps to Reproduce

See above model

Possible Solution

No response

Context

No response

Smithy-Kotlin version

1.2.18

Platform (JVM/JS/Native)

JVM

Operating system and version

(n/a)

@ianbotsf ianbotsf added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jul 25, 2024
@ianbotsf ianbotsf removed the needs-triage This issue or PR still needs to be triaged. label Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug.
Projects
None yet
Development

No branches or pull requests

1 participant