Building a Kotlin Compiler Plugin for Compose Insights
summary
Builds two plugins — a front-end plugin that inspects FIR function calls and enforces a restricted scope annotation on slot lambdas, emitting compiler errors when a composable is not a member of the receiver; and a backend plugin that injects a call to a runtime composition tracker into composable block bodies via IR transformation. Project includes Gradle + CLI plumbing, a runtime library with a CompositionLocal, and UI tests that assert exact recomposition counts (demo shows asserting two recompositions).
AI-written summary · about
chapters (10)
- 0:00Compiler plugins intro
- 2:28Plugins for large teams
- 5:13Tool for code analysis
- 9:03Front-end vs backend plugins
- 10:06Front-end plugin for Compose slots
- 18:07Project setup with Gradle
- 20:11FIR checker for restricted composables
- 26:31Backend plugin for composition tracking
- 31:11IR transformer for code injection
- 36:24Testing and validating plugins
related talks
45mCompiler plugins: modifying and analyzing Compose
36mWriting a Kotlin Compiler Plugin
29mA Hitchhiker's Guide to Compose Compiler: Composers, Compiler Plugins, and Snapshots
39mA Hitchhiker's Guide to Compose Compiler: Composers, Compiler Plugins, and Snapshots
43mCrash Course on the Kotlin Compiler
28mA Hitchhiker's Guide to Compose Compiler: Composers, Compiler Plugins, and Snapshots
36mMeta-programming with Kotlin compiler plugins
01h 13mThe Magic of Kotlin Compiler Extensions
