Esya Bekasova
10/16/2026, 8:14 PMresolvedReturnType of a FirVariableSymbol in FirDeclarationGenerationExtension? I successfully used FirAdditionalCheckersExtension to run my parser and validator, but today I started adding FirDeclarationGenerationExtension and thought it would be a great idea to make FirDeclarationGenerationExtension the entry point in logic (KSP-style pipeline)...
It seems that wasn't the best idea. Now I've started reworking the parsing for two-pass. Btw, later I even found this: github.com/google/kotlin/blob/…/FirLombokBuilderChecker.kt#…
I couldn't find an explanation in the compiler code (2.4.0), and I also couldn't find a way to log the current phase (I tried to find FirResolvedPhase.currentPhase(), similar to Thread)Esya Bekasova
10/16/2026, 8:17 PM@KMixin(Creeper::class, Side.Common)
abstract class CreeperMixin(@Origin val creeper: Creeper) {
@Extension fun boom(): String = ":p"
}
And I will generate this (virtual):
fun Creeper.boom(): String =
(this as CreeperMixin_Duck).`example_mod$boom`() // calls KSP-generated Java boilerplate
Also detailed schema:
[ @KMixin ]
│
├─────── (FIR+IR Plugin) ──────► Replaces extension calls with zero-cost duck casts
│
└────────── (KSP) ─────────────► Generates Java Duck Interface
│
▼
[ Generated Java Mixin ] ◄── (Processed at runtime by SpongePowered Mixin engine)
│
▼
[ Kotlin Impl Bridge ]
(this is Minecraft modding tooling)Esya Bekasova
10/16/2026, 8:23 PMFirDeclarationGenerationExtension will only parse @Extension as much as its phase allows. FirAdditionalCheckersExtension will parse the entire thing (because the BODY_RESOLVE phase is enough for me).Esya Bekasova
10/16/2026, 8:30 PMYoussef Shoaib [MOD]
10/16/2026, 10:45 PMresolvedReturnType in FirDeclarationGenerationExtension.
I'm not sure what you were doing before in FirAdditionalCheckersExtension to run your parser, but you're not reallyyyy supposed to do things other than checking in there; you're definitely not supposed to modify FIR in there either (i.e. there's no guarantee it'll continue working); it's really fun to break these rules, though!
Anyway, I think you could use .fir.returnTypeRef instead, or resolvedReturnType and catch the error maybe? Don't quote me on this.
Actually wait, what exactly were you doing with FirAdditionalCheckersExtension? Are you just trying to access the fully resolved code to then produce a file or similar from it? If so, just use an IR pluginEsya Bekasova
10/17/2026, 4:45 AMFirAdditionalCheckersExtension comes from my multi-frontend architecture:
My core validation logic is fully abstracted to work identically across both KSP and K2. To reuse that shared validator, I need to parse declarations into my domain model at the same level of fidelity that KSP provides (fully resolved types, annotation arguments, etc.).
So in the checker, I simply:
1. Run my FIR parser on the class symbol if it has KMixin annotation.
2. Feed the parsed model into coreValidator.
3. Receive domain models + diagnostic reports.
4. Iterate over those reports and emit them via reporter.reportOn(...).
Overall, my plugin has 3 main goals:
1. Highlight errors as the user types (handled nicely by FirAdditionalCheckersExtension).
2. Provide generated @Extension signatures in FIR so IDE autocompletion and calls work smoothly, then lower them to zero-cost duck casts in IR.
3. Attach parsed domain data to symbol attributes (FirDeclarationDataKey) so an upcoming IDEA plugin can read and make things.
Goal #1 was working smoothly, but yesterday I started working on Goal #2 (FirDeclarationGenerationExtension) and thought: "Hey, why not move the whole parsing logic there and make it the single entry point?" That's when I hit the phase wall.
So now I've reverted the checker back to how it was. I'll handle declaration generation as a separate, lightweight pass, and the main parser/validator will simply report a diagnostic error if someone tries to use an implicit return type on @Extension!Esya Bekasova
10/17/2026, 4:49 AMYoussef Shoaib [MOD]
10/17/2026, 8:45 AM