KSP2: Calling KSP2 in programs does not appear to work on macOS or Windows
ZacSweers opened this issue · comments
It looks like something changed in 1.0.21 around file module ownership. I looked at the “Calling KSP2 in Programs” docs and they don’t mention anything specific for setting up modules. When I look in the debugger, I do see a module there, but I’m not able to breakpoint it (it appears the class files don’t match published sources). Functionally, it just doesn’t seem to match the contains
call when it checks if the virtual file is in the module’s content scope.
This effectively breaks compile testing KSP plugins as well as I’m not able to figure out a workaround. PR is here: ZacSweers/kotlin-compile-testing#196
logging: No services were given. Not running kapt steps.
v: [ksp] round 1 of processing
Cannot find a KtModule for the VirtualFile
ksp.org.jetbrains.kotlin.utils.KotlinExceptionWithAttachments: Cannot find a KtModule for the VirtualFile
at ksp.org.jetbrains.kotlin.analysis.project.structure.impl.KtStandaloneProjectStructureProvider.getModule(KtStandaloneProjectStructureProvider.kt:62)
at ksp.org.jetbrains.kotlin.analysis.project.structure.ProjectStructureProvider$Companion.getModule(ProjectStructureProvider.kt:105)
at ksp.org.jetbrains.kotlin.analysis.low.level.api.fir.api.LLFirResolveSessionKt.getModule(LLFirResolveSession.kt:103)
at ksp.org.jetbrains.kotlin.analysis.low.level.api.fir.state.LLFirResolvableResolveSession.getModuleComponentsForElement(LLFirResolvableResolveSession.kt:56)
at ksp.org.jetbrains.kotlin.analysis.low.level.api.fir.state.LLFirResolvableResolveSession.getOrBuildFirFile$low_level_api_fir(LLFirResolvableResolveSession.kt:51)
at ksp.org.jetbrains.kotlin.analysis.low.level.api.fir.api.LowLevelFirApiFacadeKt.getOrBuildFirFile(LowLevelFirApiFacade.kt:137)
at ksp.org.jetbrains.kotlin.analysis.api.fir.symbols.KtFirSymbolProvider.getFileSymbol(KtFirSymbolProvider.kt:57)
at ksp.org.jetbrains.kotlin.analysis.api.symbols.KtSymbolProviderMixIn.getFileSymbol(KtSymbolProvider.kt:137)
at com.google.devtools.ksp.impl.KotlinSymbolProcessing.prepareNewKSFiles(KotlinSymbolProcessing.kt:403)
at com.google.devtools.ksp.impl.KotlinSymbolProcessing.execute(KotlinSymbolProcessing.kt:552)
at com.tschuchort.compiletesting.Ksp2PrecursorTool.execute(Ksp2.kt:116)
This issue should be fixed by #1925