[IR] Don't pass originalCallee to the inliner

`originalCallee` is supposed to be the owner of the original call.
It can be a fake override, and in the inliner we are using actual
function with body. Apparently we can just stick with the resolved
function.

#KT-64807
This commit is contained in:
Ivan Kylchik
2024-02-19 19:05:15 +01:00
committed by Space Team
parent 0258927d33
commit 2bfd1c8f23
2 changed files with 6 additions and 4 deletions
@@ -57,7 +57,10 @@ abstract class UsefulDeclarationProcessor(
super.visitBlock(expression, data)
if (expression is IrReturnableBlock) {
expression.inlineFunction?.addToUsefulPolyfilledDeclarations()
// We need to extract `originalFunction` here because saved `inlineFunction`
// is actually a copy made in `SaveInlineFunctionsBeforeInlining`.
// Without this, we are not going to find proper intersection in the `saveOnlyIntersectionOfNextDeclarationsFor` method.
expression.inlineFunction?.originalFunction?.addToUsefulPolyfilledDeclarations()
}
}
@@ -123,7 +123,7 @@ class FunctionInlining(
?: containerScope?.irElement as? IrDeclarationParent
?: (containerScope?.irElement as? IrDeclaration)?.parent
val inliner = Inliner(expression, actualCallee, target, currentScope ?: containerScope!!, parent, context)
val inliner = Inliner(expression, actualCallee, currentScope ?: containerScope!!, parent, context)
return inliner.inline().markAsRegenerated()
}
@@ -149,7 +149,6 @@ class FunctionInlining(
private inner class Inliner(
val callSite: IrFunctionAccessExpression,
val callee: IrFunction,
val originalCallee: IrFunction,
val currentScope: ScopeWithIr,
val parent: IrDeclarationParent?,
val context: CommonBackendContext
@@ -169,7 +168,7 @@ class FunctionInlining(
val substituteMap = mutableMapOf<IrValueParameter, IrExpression>()
fun inline() = inlineFunction(callSite, callee, originalCallee, true)
fun inline() = inlineFunction(callSite, callee, callee, true)
private fun <E : IrElement> E.copy(): E {
@Suppress("UNCHECKED_CAST")