I have a case where `IrPluginContext.referenceFunc...
# compiler
o
I have a case where
IrPluginContext.referenceFunctions(callableId: CallableId)
does not resolve a symbol (returning an empty collection) resolves to two symbols when called at the beginning of
IrGenerationExtension.generate()
, but then properly resolves to a single symbol later on during
IrModuleFragment.transform
. The situation only occurs with the Android Gradle Library Plugin for KMP and only with Android Local tests (a.k.a. host-based tests, unit tests). Why is that? More Details in 🧵.
Here is a reproducer (follow the steps in the AndroidHostTest Dance section to observe the quirky behavior). Changing this line to lazy resolution as follows resolves the problem:
Copy code
val configureAndExecuteTestsFunctionSymbol by lazy {
    irFunctionSymbol(internalPackageName, "configureAndExecuteTests")
}
What's also remarkable in this case that the original eager name resolution works if we invoke the Gradle task multiple times, removing and re-adding a test dependency along the way (that's what the AndroidHostTest Dance does.