[FIR2IR] Allow symbolTable cache lookups if IR f/o builder mode is enabled

Without this change, the following test is failing:
- FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated.Collections.testInheritFromHashtable

^KT-58861
This commit is contained in:
Dmitriy Novozhilov
2023-09-12 14:58:55 +03:00
committed by Space Team
parent 9a109e98ce
commit 0e92f98031
@@ -1018,15 +1018,29 @@ class Fir2IrDeclarationStorage(
*/
signatureCalculator()?.let { signature ->
val cachedInSymbolTable = referenceIfAny(signature) ?: return@let
if (isFakeOverride) {
val key = FakeOverrideIdentifier(
declaration.symbol.unwrapFakeOverrides(),
fakeOverrideOwnerLookupTag ?: declaration.containingClassLookupTag()!!
)
irFakeOverridesForFirFakeOverrideMap[key] = cachedInSymbolTable
return cachedInSymbolTable
} else {
error("IR declaration with signature $signature found in SymbolTable and not found in declaration storage")
when {
isFakeOverride -> {
val key = FakeOverrideIdentifier(
declaration.symbol.unwrapFakeOverrides(),
fakeOverrideOwnerLookupTag ?: declaration.containingClassLookupTag()!!
)
irFakeOverridesForFirFakeOverrideMap[key] = cachedInSymbolTable
return cachedInSymbolTable
}
configuration.useIrFakeOverrideBuilder -> {
/*
* If IR fake override builder is used for building fake-overrides, they are generated bypassing Fir2IrDeclarationStorage,
* and are written directly to SymbolTable. So in this case it is normal to save the result from symbol table into
* storage
*
* TODO: potentially this situation won't happen after migration from FIR2IR f/o generator to IR f/o generator (see KT-58861)
*/
cache[declaration] = cachedInSymbolTable
return cachedInSymbolTable
}
else -> {
error("IR declaration with signature $signature found in SymbolTable and not found in declaration storage")
}
}
}