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

Unqualified types in union variants can cause incorrect inference #867

Closed
aajtodd opened this issue Jun 16, 2023 · 0 comments · Fixed by #868
Closed

Unqualified types in union variants can cause incorrect inference #867

aajtodd opened this issue Jun 16, 2023 · 0 comments · Fixed by #868
Labels
bug This issue is a bug.

Comments

@aajtodd
Copy link
Contributor

aajtodd commented Jun 16, 2023

Describe the bug

A model with a union type such as

union MyUnion {
    string: String
    foo: UnionMap
}

map UnionMap {
    key: String
    value: MyUnion
}

Will generate a sealed class like this:

sealed class MyUnion {
    class String(val value: kotlin.String): MyUnion()

     class Foo(val value: Map<String, MyUnion>): MyUnion()
}

This causes the generated type to be Map<MyUnion.String, MyUnion> instead of the intended Map<kotlin.String, MyUnion>. Unions are already generated as fully qualified for similar issues we've seen in the past. It would seem we need to fully qualify generic bounds as well.

Expected Behavior

The map generic types need to be fully qualified as well:

sealed class MyUnion {
    class String(val value: kotlin.String): MyUnion()

     class Foo(val value: Map<kotlin.String, com.package.model.MyUnion>): MyUnion()
}
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
1 participant