[FIR2IR] Extract logic of IR declarations generation into separate component. Part 5

Move caching of created IrConstructor back to Fir2IrDeclarationStorage

^KT-61513
This commit is contained in:
Dmitriy Novozhilov
2023-08-28 13:10:50 +03:00
committed by Space Team
parent 6621b16e77
commit e83dc35ba5
2 changed files with 14 additions and 1 deletions
@@ -509,6 +509,11 @@ class Fir2IrDeclarationStorage(
return callablesGenerator.createIrConstructor(constructor, irParent, predefinedOrigin, isLocal)
}
@LeakedDeclarationCaches
internal fun cacheIrConstructor(constructor: FirConstructor, irConstructor: IrConstructor) {
constructorCache[constructor] = irConstructor
}
fun getOrCreateIrProperty(
property: FirProperty,
irParent: IrDeclarationParent?,
@@ -1068,3 +1073,10 @@ internal fun FirCallableDeclaration.isFakeOverride(fakeOverrideOwnerLookupTag: C
private object IsStubPropertyForPureFieldKey : FirDeclarationDataKey()
internal var FirProperty.isStubPropertyForPureField: Boolean? by FirDeclarationDataRegistry.data(IsStubPropertyForPureFieldKey)
/**
* Opt-in to this annotation indicates that some code uses annotated function but it actually shouldn't
* See KT-61513
*/
@RequiresOptIn
annotation class LeakedDeclarationCaches
@@ -410,7 +410,8 @@ class Fir2IrCallableDeclarationsGenerator(val components: Fir2IrComponents) : Fi
metadata = FirMetadataSource.Function(constructor)
// Add to cache before generating parameters to prevent an infinite loop when an annotation value parameter is annotated
// with the annotation itself.
constructorCache[constructor] = this
@OptIn(LeakedDeclarationCaches::class)
declarationStorage.cacheIrConstructor(constructor, this)
declarationStorage.withScope(symbol) {
setAndModifyParent(this, irParent)
declareParameters(constructor, irParent, dispatchReceiverType = null, isStatic = false, forSetter = false)