[FIR2IR] Cache generated IR functions for data/value classes in declarations storage
Previously, DataClassMembersGenerator saved generated functions only in symbol table, which led to the situation when there is a FIR function in scopes, IR function in symbol table but no record about their relation in Fir2IrDeclarationStorage ^KT-61637
This commit is contained in:
committed by
Space Team
parent
58e8dfc23b
commit
a3498bdd91
@@ -352,6 +352,10 @@ class Fir2IrDeclarationStorage(
|
||||
delegatedReverseCache[irFunction] = function
|
||||
}
|
||||
|
||||
internal fun cacheGeneratedFunction(firFunction: FirSimpleFunction, irFunction: IrSimpleFunction) {
|
||||
functionCache[firFunction] = irFunction
|
||||
}
|
||||
|
||||
// ------------------------------------ constructors ------------------------------------
|
||||
|
||||
@OptIn(IrSymbolInternals::class)
|
||||
|
||||
+4
-1
@@ -198,6 +198,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
||||
components.irBuiltIns.stringType,
|
||||
)
|
||||
irClass.declarations.add(toStringFunction)
|
||||
declarationStorage.cacheGeneratedFunction(toStringContributedFunction, toStringFunction)
|
||||
}
|
||||
|
||||
val hashcodeNameContributedFunction = contributedSyntheticFunctions[HASHCODE_NAME]
|
||||
@@ -209,6 +210,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
||||
components.irBuiltIns.intType,
|
||||
)
|
||||
irClass.declarations.add(hashCodeFunction)
|
||||
declarationStorage.cacheGeneratedFunction(hashcodeNameContributedFunction, hashCodeFunction)
|
||||
}
|
||||
|
||||
val equalsContributedFunction = contributedSyntheticFunctions[EQUALS]
|
||||
@@ -222,6 +224,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
||||
isOperator = true
|
||||
)
|
||||
irClass.declarations.add(equalsFunction)
|
||||
declarationStorage.cacheGeneratedFunction(equalsContributedFunction, equalsFunction)
|
||||
}
|
||||
|
||||
return result
|
||||
@@ -291,7 +294,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) : Fir2IrCompon
|
||||
returnType: IrType,
|
||||
otherParameterNeeded: Boolean = false,
|
||||
isOperator: Boolean = false,
|
||||
): IrFunction {
|
||||
): IrSimpleFunction {
|
||||
val signature = if (klass.symbol.classId.isLocal) null else components.signatureComposer.composeSignature(syntheticCounterpart)
|
||||
return components.callablesGenerator.declareIrSimpleFunction(signature) { symbol ->
|
||||
components.irFactory.createSimpleFunction(
|
||||
|
||||
Reference in New Issue
Block a user