Hi! I want to generate default `toString()` implem...
# compiler
g
Hi! I want to generate default
toString()
implementation for
object
classes. How I can do that? Should I use kapt or is there some way to do it via compiler plugin?
s
Hey, I think the best way of approaching that is through a compiler plugin. If you are only modifying the implementation of toString, you don't have to change much, mostly generating new method body through IR. I did a similar in implementation thing for an old backend, write-up here: https://medium.com/bumble-tech/fixing-serialization-of-kotlin-objects-once-and-for-all-95886fddba7a The example repo should also contain implementation for the new IR backend, albeit with an older version of compiler (a thing or two have changed since ;))
👍 1