[IR] Distinguish super calls from other calls

Otherwise super call and virtual call to the same method get the same
map key in case of Fir2Ir IR generation
This commit is contained in:
Andrey Zinovyev
2021-05-17 17:12:36 +03:00
committed by TeamCityServer
parent 60bc0f4baf
commit 709c127f1b
2 changed files with 8 additions and 3 deletions
@@ -70,7 +70,13 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle
private data class FieldKey(val fieldSymbol: IrFieldSymbol, val parent: IrDeclarationParent, val superQualifierSymbol: IrClassSymbol?)
private val functionMap = mutableMapOf<Pair<IrFunctionSymbol, IrDeclarationParent>, IrFunctionSymbol>()
private data class FunctionKey(
val functionSymbol: IrFunctionSymbol,
val parent: IrDeclarationParent,
val superQualifierSymbol: IrClassSymbol?
)
private val functionMap = mutableMapOf<FunctionKey, IrFunctionSymbol>()
private val getterMap = mutableMapOf<FieldKey, IrSimpleFunctionSymbol>()
private val setterMap = mutableMapOf<FieldKey, IrSimpleFunctionSymbol>()
@@ -157,7 +163,7 @@ internal class SyntheticAccessorLowering(val context: JvmBackendContext) : IrEle
// For the call to super.g in function i, the accessor to A.g must be produced in C. Therefore, we
// cannot use the function symbol (A.g in the example) by itself as the key since there should be
// one accessor per dispatch receiver (i.e., parent of the accessor).
return functionMap.getOrPut(symbol to parent) {
return functionMap.getOrPut(FunctionKey(symbol, parent, superQualifierSymbol)) {
when (symbol) {
is IrConstructorSymbol ->
symbol.owner.makeConstructorAccessor()
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// FILE: 1.kt