[FIR2IR] Rename some entities in Fir2IrDeclarationStorage

In the previous commit, we started to treat delegated function similarly
  to substitution/intersection overrides, so now it's incorrect to name
  corresponding methods and storages using "fake-override" word

^KT-62671
This commit is contained in:
Dmitriy Novozhilov
2023-10-19 11:53:36 +03:00
committed by Space Team
parent 940567978d
commit 402e4e3af4
2 changed files with 23 additions and 23 deletions
@@ -48,7 +48,7 @@ class Fir2IrCommonMemberStorage(
val propertyForBackingFieldCache: ConcurrentHashMap<IrFieldSymbol, IrPropertySymbol> = ConcurrentHashMap() val propertyForBackingFieldCache: ConcurrentHashMap<IrFieldSymbol, IrPropertySymbol> = ConcurrentHashMap()
val delegateVariableForPropertyCache: ConcurrentHashMap<IrLocalDelegatedPropertySymbol, IrVariableSymbol> = ConcurrentHashMap() val delegateVariableForPropertyCache: ConcurrentHashMap<IrLocalDelegatedPropertySymbol, IrVariableSymbol> = ConcurrentHashMap()
val fakeOverridesInClass: MutableMap<IrClass, MutableMap<Fir2IrDeclarationStorage.FakeOverrideKey, FirCallableDeclaration>> = mutableMapOf() val fakeOverridesInClass: MutableMap<IrClass, MutableMap<Fir2IrDeclarationStorage.FirOverrideKey, FirCallableDeclaration>> = mutableMapOf()
val irFakeOverridesForFirFakeOverrideMap: MutableMap<Fir2IrDeclarationStorage.FakeOverrideIdentifier, IrDeclaration> = mutableMapOf() val irForFirSessionDependantDeclarationMap: MutableMap<Fir2IrDeclarationStorage.FakeOverrideIdentifier, IrDeclaration> = mutableMapOf()
} }
@@ -107,36 +107,37 @@ class Fir2IrDeclarationStorage(
// //
// Note: reusing is necessary here, because sometimes (see testFakeOverridesInPlatformModule) // Note: reusing is necessary here, because sometimes (see testFakeOverridesInPlatformModule)
// we have to match fake override in platform class with overridden fake overrides in common class // we have to match fake override in platform class with overridden fake overrides in common class
private val fakeOverridesInClass: MutableMap<IrClass, MutableMap<FakeOverrideKey, FirCallableDeclaration>> = private val fakeOverridesInClass: MutableMap<IrClass, MutableMap<FirOverrideKey, FirCallableDeclaration>> =
commonMemberStorage.fakeOverridesInClass commonMemberStorage.fakeOverridesInClass
/* /*
* FIR declarations for substitution and intersection overrides are session dependent, which means that in MPP project * FIR declarations for substitution and intersection overrides, and also for delegated members are session dependent,
* we can have two different functions for the same substitution overrides (in common and platform modules) * which means that in an MPP project we can have two different functions for the same substitution overrides
* (in common and platform modules)
* *
* So this cache is needed to have only one IR declaration for both overrides * So this cache is needed to have only one IR declaration for both overrides
* *
* The key here is a pair of the original function (first not f/o) and lookup tag of class for which this fake override was created * The key here is a pair of the original function (first not f/o) and lookup tag of class for which this fake override was created
* THe value is IR function, build for this fake override during fir2ir translation of the module that contains parent class of this function * THe value is IR function, build for this fake override during fir2ir translation of the module that contains parent class of this function
*/ */
private val irFakeOverridesForFirFakeOverrideMap: MutableMap<FakeOverrideIdentifier, IrDeclaration> = private val irForFirSessionDependantDeclarationMap: MutableMap<FakeOverrideIdentifier, IrDeclaration> =
commonMemberStorage.irFakeOverridesForFirFakeOverrideMap commonMemberStorage.irForFirSessionDependantDeclarationMap
data class FakeOverrideIdentifier(val originalSymbol: FirCallableSymbol<*>, val dispatchReceiverLookupTag: ConeClassLikeLookupTag) data class FakeOverrideIdentifier(val originalSymbol: FirCallableSymbol<*>, val dispatchReceiverLookupTag: ConeClassLikeLookupTag)
sealed class FakeOverrideKey { sealed class FirOverrideKey {
data class Signature(val signature: IdSignature) : FakeOverrideKey() data class Signature(val signature: IdSignature) : FirOverrideKey()
/* /*
* Used for declarations which don't have id signature (e.g. members of local classes) * Used for declarations which don't have id signature (e.g. members of local classes)
*/ */
data class Declaration(val declaration: FirCallableDeclaration) : FakeOverrideKey() data class Declaration(val declaration: FirCallableDeclaration) : FirOverrideKey()
} }
private fun FirCallableDeclaration.asFakeOverrideKey(): FakeOverrideKey { private fun FirCallableDeclaration.asFakeOverrideKey(): FirOverrideKey {
return when (val signature = signatureComposer.composeSignature(this)) { return when (val signature = signatureComposer.composeSignature(this)) {
null -> FakeOverrideKey.Declaration(this) null -> FirOverrideKey.Declaration(this)
else -> FakeOverrideKey.Signature(signature) else -> FirOverrideKey.Signature(signature)
} }
} }
@@ -320,13 +321,13 @@ class Fir2IrDeclarationStorage(
localStorage.putLocalFunction(function, irFunction) localStorage.putLocalFunction(function, irFunction)
} }
function.isFakeOverride(fakeOverrideOwnerLookupTag) -> { function.isFakeOverrideOrDelegated(fakeOverrideOwnerLookupTag) -> {
val originalFunction = function.unwrapFakeOverridesOrDelegated() val originalFunction = function.unwrapFakeOverridesOrDelegated()
val key = FakeOverrideIdentifier( val key = FakeOverrideIdentifier(
originalFunction.symbol, originalFunction.symbol,
fakeOverrideOwnerLookupTag ?: function.containingClassLookupTag()!! fakeOverrideOwnerLookupTag ?: function.containingClassLookupTag()!!
) )
irFakeOverridesForFirFakeOverrideMap[key] = irFunction irForFirSessionDependantDeclarationMap[key] = irFunction
} }
else -> { else -> {
@@ -515,13 +516,13 @@ class Fir2IrDeclarationStorage(
irProperty.setter?.let { irProperty.setter?.let {
setterForPropertyCache[irPropertySymbol] = it.symbol setterForPropertyCache[irPropertySymbol] = it.symbol
} }
if (property.isFakeOverride(fakeOverrideOwnerLookupTag)) { if (property.isFakeOverrideOrDelegated(fakeOverrideOwnerLookupTag)) {
val originalProperty = property.unwrapFakeOverridesOrDelegated() val originalProperty = property.unwrapFakeOverridesOrDelegated()
val key = FakeOverrideIdentifier( val key = FakeOverrideIdentifier(
originalProperty.symbol, originalProperty.symbol,
fakeOverrideOwnerLookupTag ?: property.containingClassLookupTag()!! fakeOverrideOwnerLookupTag ?: property.containingClassLookupTag()!!
) )
irFakeOverridesForFirFakeOverrideMap[key] = irProperty irForFirSessionDependantDeclarationMap[key] = irProperty
} else { } else {
propertyCache[property] = irProperty propertyCache[property] = irProperty
} }
@@ -902,13 +903,13 @@ class Fir2IrDeclarationStorage(
* *
* To workaround this, we look up such declarations in both caches. * To workaround this, we look up such declarations in both caches.
*/ */
val isFakeOverride = declaration.isFakeOverride(fakeOverrideOwnerLookupTag) val isFakeOverride = declaration.isFakeOverrideOrDelegated(fakeOverrideOwnerLookupTag)
if (isFakeOverride) { if (isFakeOverride) {
val key = FakeOverrideIdentifier( val key = FakeOverrideIdentifier(
declaration.unwrapFakeOverrides().symbol, declaration.unwrapFakeOverridesOrDelegated().symbol,
fakeOverrideOwnerLookupTag ?: declaration.containingClassLookupTag()!! fakeOverrideOwnerLookupTag ?: declaration.containingClassLookupTag()!!
) )
irFakeOverridesForFirFakeOverrideMap[key]?.let { return it as IC } irForFirSessionDependantDeclarationMap[key]?.let { return it as IC }
} else { } else {
cache[declaration]?.let { return it } cache[declaration]?.let { return it }
} }
@@ -956,7 +957,7 @@ class Fir2IrDeclarationStorage(
declaration.symbol.unwrapFakeOverrides(), declaration.symbol.unwrapFakeOverrides(),
fakeOverrideOwnerLookupTag ?: declaration.containingClassLookupTag()!! fakeOverrideOwnerLookupTag ?: declaration.containingClassLookupTag()!!
) )
irFakeOverridesForFirFakeOverrideMap[key] = cachedInSymbolTable irForFirSessionDependantDeclarationMap[key] = cachedInSymbolTable
} }
configuration.useIrFakeOverrideBuilder -> { configuration.useIrFakeOverrideBuilder -> {
/* /*
@@ -1154,7 +1155,7 @@ class Fir2IrDeclarationStorage(
} }
} }
internal fun FirCallableDeclaration.isFakeOverride(fakeOverrideOwnerLookupTag: ConeClassLikeLookupTag?): Boolean { private fun FirCallableDeclaration.isFakeOverrideOrDelegated(fakeOverrideOwnerLookupTag: ConeClassLikeLookupTag?): Boolean {
if (isCopyCreatedInScope) return true if (isCopyCreatedInScope) return true
if (fakeOverrideOwnerLookupTag == null) return false if (fakeOverrideOwnerLookupTag == null) return false
// this condition is true for all places when we are trying to create "fake" fake overrides in IR // this condition is true for all places when we are trying to create "fake" fake overrides in IR
@@ -1162,7 +1163,6 @@ internal fun FirCallableDeclaration.isFakeOverride(fakeOverrideOwnerLookupTag: C
return fakeOverrideOwnerLookupTag != containingClassLookupTag() return fakeOverrideOwnerLookupTag != containingClassLookupTag()
} }
private object IsStubPropertyForPureFieldKey : FirDeclarationDataKey() private object IsStubPropertyForPureFieldKey : FirDeclarationDataKey()
internal var FirProperty.isStubPropertyForPureField: Boolean? by FirDeclarationDataRegistry.data(IsStubPropertyForPureFieldKey) internal var FirProperty.isStubPropertyForPureField: Boolean? by FirDeclarationDataRegistry.data(IsStubPropertyForPureFieldKey)