Meta-programming with Kotlin compiler plugins
summary
Demo of a Kotlin compiler plugin that uses the K2 front-end and FIR extension register adapter to install a status transformer which flips private callable visibility to public; project uses Gradle KTS, compileOnly kotlin-compiler dependencies and a service file, runs with the compiler in-process so breakpoints hit (debug in-process). The example compiles and a private function is callable across files. Caveats: longer compile times, larger binaries, hard maintenance and unstable compiler APIs; prefer KSP when not modifying existing code.
AI-written summary · about
chapters (12)
- 0:00Introduction to meta-programming
- 1:28Meta-programming in Kotlin
- 7:55Kotlin 2.0 compiler plugins
- 9:23Plugin structure overview
- 13:21Building a plugin step-by-step
- 21:45Debugging the plugin
- 23:10Modifying visibility with plugin
- 28:59Hard lessons learned
- 31:51Resources and tools
- 33:58Testing Kotlin compiler plugins
- 35:25KSP vs compiler plugins
- 36:09Q&A
related talks
42mMeta-programming with K2 compiler plugins
33mMeta-programming with KSP and Kotlin compiler plugins
36mWriting a Kotlin Compiler Plugin
44mMeta-programming with KSP and Kotlin compiler plugins
43mWriting Your First Kotlin Compiler Plugin
38mKSP and Plugins. Optimizing Kotlin Multiplatform common code
37mBuilding a Kotlin Compiler Plugin for Compose Insights
01h 13mThe Magic of Kotlin Compiler Extensions
