[FIR2IR] Extract logic of IR declarations generation into separate component. Part 9
Move caching of created lazy declarations back to Fir2IrDeclarationStorage
This commit is contained in:
committed by
Space Team
parent
6e2123c2b6
commit
c215df8b93
+21
-5
@@ -454,6 +454,12 @@ class Fir2IrDeclarationStorage(
|
|||||||
isLocal = isLocal,
|
isLocal = isLocal,
|
||||||
fakeOverrideOwnerLookupTag = fakeOverrideOwnerLookupTag
|
fakeOverrideOwnerLookupTag = fakeOverrideOwnerLookupTag
|
||||||
)
|
)
|
||||||
|
cacheIrFunction(function, irFunction, fakeOverrideOwnerLookupTag)
|
||||||
|
|
||||||
|
return irFunction
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun cacheIrFunction(function: FirFunction, irFunction: IrSimpleFunction, fakeOverrideOwnerLookupTag: ConeClassLikeLookupTag?) {
|
||||||
when {
|
when {
|
||||||
irFunction.visibility == DescriptorVisibilities.LOCAL -> {
|
irFunction.visibility == DescriptorVisibilities.LOCAL -> {
|
||||||
localStorage.putLocalFunction(function, irFunction)
|
localStorage.putLocalFunction(function, irFunction)
|
||||||
@@ -472,8 +478,6 @@ class Fir2IrDeclarationStorage(
|
|||||||
functionCache[function] = irFunction
|
functionCache[function] = irFunction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return irFunction
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getOrCreateIrAnonymousInitializer(
|
fun getOrCreateIrAnonymousInitializer(
|
||||||
@@ -547,6 +551,15 @@ class Fir2IrDeclarationStorage(
|
|||||||
fakeOverrideOwnerLookupTag: ConeClassLikeLookupTag? = null
|
fakeOverrideOwnerLookupTag: ConeClassLikeLookupTag? = null
|
||||||
): IrProperty {
|
): IrProperty {
|
||||||
val irProperty = callablesGenerator.createIrProperty(property, irParent, predefinedOrigin, isLocal, fakeOverrideOwnerLookupTag)
|
val irProperty = callablesGenerator.createIrProperty(property, irParent, predefinedOrigin, isLocal, fakeOverrideOwnerLookupTag)
|
||||||
|
cacheIrProperty(property, irProperty, fakeOverrideOwnerLookupTag)
|
||||||
|
return irProperty
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun cacheIrProperty(
|
||||||
|
property: FirProperty,
|
||||||
|
irProperty: IrProperty,
|
||||||
|
fakeOverrideOwnerLookupTag: ConeClassLikeLookupTag?,
|
||||||
|
) {
|
||||||
val irPropertySymbol = irProperty.symbol
|
val irPropertySymbol = irProperty.symbol
|
||||||
irProperty.backingField?.symbol?.let {
|
irProperty.backingField?.symbol?.let {
|
||||||
backingFieldForPropertyCache[irPropertySymbol] = it
|
backingFieldForPropertyCache[irPropertySymbol] = it
|
||||||
@@ -568,7 +581,6 @@ class Fir2IrDeclarationStorage(
|
|||||||
} else {
|
} else {
|
||||||
propertyCache[property] = irProperty
|
propertyCache[property] = irProperty
|
||||||
}
|
}
|
||||||
return irProperty
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FirField.toStubProperty(): FirProperty {
|
private fun FirField.toStubProperty(): FirProperty {
|
||||||
@@ -828,7 +840,9 @@ class Fir2IrDeclarationStorage(
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
createIrLazyDeclaration = { signature, lazyParent, declarationOrigin ->
|
createIrLazyDeclaration = { signature, lazyParent, declarationOrigin ->
|
||||||
lazyDeclarationsGenerator.createIrLazyFunction(fir, signature, lazyParent, declarationOrigin)
|
lazyDeclarationsGenerator.createIrLazyFunction(fir, signature, lazyParent, declarationOrigin).also {
|
||||||
|
cacheIrFunction(fir, it, fakeOverrideOwnerLookupTag = null)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
) as IrFunctionSymbol
|
) as IrFunctionSymbol
|
||||||
if (unmatchedOwner && fakeOverrideOwnerLookupTag is ConeClassLookupTagWithFixedSymbol) {
|
if (unmatchedOwner && fakeOverrideOwnerLookupTag is ConeClassLookupTagWithFixedSymbol) {
|
||||||
@@ -871,7 +885,9 @@ class Fir2IrDeclarationStorage(
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
createIrLazyDeclaration = { signature, lazyParent, declarationOrigin ->
|
createIrLazyDeclaration = { signature, lazyParent, declarationOrigin ->
|
||||||
lazyDeclarationsGenerator.createIrLazyProperty(fir, signature, lazyParent, declarationOrigin)
|
lazyDeclarationsGenerator.createIrLazyProperty(fir, signature, lazyParent, declarationOrigin).also {
|
||||||
|
cacheIrProperty(fir, it, fakeOverrideOwnerLookupTag = null)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
-8
@@ -43,7 +43,6 @@ class Fir2IrLazyDeclarationsGenerator(val components: Fir2IrComponents) : Fir2Ir
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
functionCache[fir] = irFunction
|
|
||||||
// NB: this is needed to prevent recursions in case of self bounds
|
// NB: this is needed to prevent recursions in case of self bounds
|
||||||
(irFunction as Fir2IrLazySimpleFunction).prepareTypeParameters()
|
(irFunction as Fir2IrLazySimpleFunction).prepareTypeParameters()
|
||||||
return irFunction
|
return irFunction
|
||||||
@@ -85,13 +84,6 @@ class Fir2IrLazyDeclarationsGenerator(val components: Fir2IrComponents) : Fir2Ir
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
propertyCache[fir] = irProperty
|
|
||||||
irProperty.getter?.symbol?.let { getterForPropertyCache[symbol] = it }
|
|
||||||
irProperty.setter?.symbol?.let { setterForPropertyCache[symbol] = it }
|
|
||||||
irProperty.backingField?.symbol?.let {
|
|
||||||
backingFieldForPropertyCache[symbol] = it
|
|
||||||
propertyForBackingFieldCache[it] = symbol
|
|
||||||
}
|
|
||||||
return irProperty
|
return irProperty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user