Writing a Kotlin Compiler Plugin
summary
Shows how to build a real Kotlin compiler plugin from JetBrains’ compiler-plugin-template with three modules (annotations, compiler, Gradle hook), hooks into FIR and IR extensions, and implements concrete features: a diagnostic checker that flags unsafe use of check/require, an @Log annotation that injects print statements at function entry/exit (parameters and return), test validation using generated .fir/.ir text files and the compiler devkit, and Gradle/compiler options for toggling behavior.
AI-written summary · about
chapters (15)
- 0:00Kotlin compiler plugins intro
- 1:03What is metaprogramming and its uses
- 3:36Compiler plugins vs annotation processing
- 7:27Kotlin compiler history
- 9:37Kotlin compiler internals
- 13:29Kotlin plugin project setup
- 15:18Plugin entry point and hooks
- 17:02Diagnostics in plugins
- 23:04IR code modification
- 28:04Code generation in plugins
- 29:09Testing compiler plugins
- 33:00Gradle integration
- 34:25Debugging plugins
- 34:46Notable open-source plugins
- 36:13Q&A
related talks
43mWriting Your First Kotlin Compiler Plugin
37mBuilding a Kotlin Compiler Plugin for Compose Insights
01h 13mThe Magic of Kotlin Compiler Extensions
36mMeta-programming with Kotlin compiler plugins
45mCompiler plugins: modifying and analyzing Compose
43mCrash Course on the Kotlin Compiler
26mBuild your own compiler with KSP
38mKSP and Plugins. Optimizing Kotlin Multiplatform common code
