Zac Sweers
01/29/2025, 3:58 AMFirSupertypeGenerationExtension
that session.predicateBasedProvider.getSymbolsByPredicate()
does not find symbols in commonMain
sources when it's running on a class defined in a jvmMain
source set.
If I hop in the debugger and manually look up an expected matching symbol, it is present and session.predicateBasedProvider.matches(predicate, symbol)
does return true. What I noticed is that two different `FirSession`s appear during the compilation, I'm guessing one for commonMain
and then a different one for jvmMain
. Their internal predicatedBasedProvider caches are limited to their own sources though. Is there any way to match these symbols from platform-specific FIR extensions?dmitriy.novozhilov
01/29/2025, 7:37 AMval moduleData = session.moduleData
val commonSessions = moduleData.allDependsOnDependencies.map { it.session }
But in general it makes sense to carefully think why do you depend on something from the other module during generation of something with your plugin. For example, how it would work for metadata compilation of the common modules?Zac Sweers
01/29/2025, 2:46 PMdmitriy.novozhilov
01/29/2025, 3:10 PMcompileKotlinPlatform
tasks in Gradle (like compileKotlinJvm
) which compile all MPP sourcesets at once and produce the resulting binaries, and also compileKotlinCommonMetadata
tasks, which compile all non-leaf modules independently to metadata klib artifacts
So if you have, for example, common -> jvmAndJs -> jvm
structure, sources of jvmAndJs
would be compiled to metadata independently, and declarations from common
will be passed as plain binary metadata dependencies.
In this situation if you want to generate something in non-leaf module, you won't have access to all sources, just one sourcestZac Sweers
01/29/2025, 3:20 PMdmitriy.novozhilov
01/29/2025, 3:23 PMdmitriy.novozhilov
01/29/2025, 3:25 PM// lib-common
fun foo(x: Int = 1) {} // (1)
// lib-jvm
fun foo() {} // (2)
// app-common
fun test() {
foo()
}
In this example the call foo()
is resolved to
• (1) during metadata compilation of app-common
• (2) during jvm compilation of app
• (1) in the IDE
After this change everything will be resolved to (1)