rharter / auto-value-gson

AutoValue Extension to add Gson De/Serializer support
Apache License 2.0
603 stars 103 forks source link

Fix missing originating element in generated adapters #234

Closed ZacSweers closed 4 years ago

ZacSweers commented 4 years ago

Fixes #233

I think before this Just Worked because the generated adapter was a nested type of a class that did have its originating element set, but when it's top-level it does need it set anyway. This sets it for both just to be doubly sure.

CC @gavra0

gavra0 commented 4 years ago

In 1.3.70 KAPT will have better logging regarding this. To figure out what is causing it to fail, you can create a breakpoint in https://github.com/JetBrains/kotlin/blob/a9686c94474c9d442db61b45f60e6ff326fdb7db/plugins/kapt3/kapt3-base/src/org/jetbrains/kotlin/kapt3/base/incremental/incrementalProcessors.kt#L119 (this is tag v1.3.61).

ZacSweers commented 4 years ago

I've figured it out. This is a bug in JavaPoet, where calling TypeSpec#toBuilder() leaves out the originating elements.

https://github.com/square/javapoet/issues/749