đź‘‹ hoping this is the right channel to ask this, I figured a lot of the discussions around the Kotlin internals happens here. I was looking at the Kotlin compiler plugins (namely, no-arg and Parcelize, which I figured were some of the simpler ones), trying to get a feel for them. I'd love to contribute to compiler plugin work at some point.
I noticed that they're generating bytecode directly:
https://github.com/JetBrains/kotlin/blob/master/plugins/noarg/noarg-cli/src/NoArgExpressionCodegenExtension.kt#L54
Is it feasible and/or desirable to generate Kotlin source code (now that KotlinPoet is a thing, though it's still early-stage from what I understand), run it through the embedded Kotlin compiler, and emit the generated bytecode from that instead? It seems more maintainable and less error-prone, at least from my perspective, to generate source code than to try to write out bytecode by hand.
Just trying to get some perspective on the way the plugins are written, I assume that one of the main reasons for writing bytecode is just that KotlinPoet is new, and compiler plugins have been a thing for a while now 🙂