Skip to content

Unions with member names matching auto-imported Kotlin symbols fail to codegen correctly #1127

@ianbotsf

Description

@ianbotsf

Describe the bug

Given a model such as:

union Foo {
    list: BarList
}

list BarList {
    member: Bar
}

string Bar

The generated code will make no attempt to differentiate between the union member Foo.List and the collection kotlin.collections.List:

public sealed class Foo {
    public data class List(val value: List<kotlin.String>) : Foo () { // Compilation error: `List` has no generic args
    }
}

We need smarter handling of Kotlin symbols when codegenning union members (and possibly elsewhere too).

Expected behavior

Shapes should codegen and compile successfully

Current behavior

Compilation fails

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions