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

Typealias breaks generated code #102

Open
Octogonapus opened this issue Jul 16, 2019 · 0 comments
Open

Typealias breaks generated code #102

Octogonapus opened this issue Jul 16, 2019 · 0 comments
Labels
bug Something isn't working meta Related with the annotation processor

Comments

@Octogonapus
Copy link
Collaborator

A data class which contains a member which is a typealias causes the generated code to be invalid.

This code:

typealias Foo = Either<String, Int>

@json
data class DataClass1(
    val foo: Foo
) {
    companion object
}

Generates this:

fun DataClass1.toJson(): Json = JsObject(mapOf(
"foo" to com.octogonapus.heliosdemo.Foo.encoder().run { foo.encode() }
))

foo.encode() is an unresolved reference.

Changing the data class to:

@json
data class DataClass1(
    val foo: Either<String, Int>
) {
    companion object
}

Generates this, which compiles fine:

fun DataClass1.toJson(): Json = JsObject(mapOf(
"foo" to arrow.core.Either.Companion.encoder(kotlin.String.encoder(), kotlin.Int.encoder()).run { foo.encode() }
))

There is a sample project containing this code here https://github.com/Octogonapus/helios-demo/tree/typealias_issue (specifically on branch typealias_issue).

@AdrianRaFo AdrianRaFo added bug Something isn't working meta Related with the annotation processor labels Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working meta Related with the annotation processor
Projects
None yet
Development

No branches or pull requests

2 participants