[IR] Fixed a problem in FunctionInlining
#KT-64868 Fixed
This commit is contained in:
+6
-4
@@ -74,7 +74,7 @@ open class DefaultInlineFunctionResolver(open val context: CommonBackendContext)
|
||||
symbol == context.ir.symbols.coroutineContextGetter ->
|
||||
context.ir.symbols.coroutineGetContext.owner
|
||||
|
||||
else -> (symbol.owner as? IrSimpleFunction)?.resolveFakeOverride() ?: symbol.owner
|
||||
else -> function
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,8 @@ class FunctionInlining(
|
||||
if (!callee.needsInlining || inlineFunctionResolver.shouldExcludeFunctionFromInlining(callee.symbol))
|
||||
return expression
|
||||
|
||||
val actualCallee = inlineFunctionResolver.getFunctionDeclaration(callee.symbol)
|
||||
val target = (callee as? IrSimpleFunction)?.resolveFakeOverride() ?: callee
|
||||
val actualCallee = inlineFunctionResolver.getFunctionDeclaration(target.symbol)
|
||||
if (actualCallee.body == null) {
|
||||
return expression
|
||||
}
|
||||
@@ -131,7 +132,7 @@ class FunctionInlining(
|
||||
?: containerScope?.irElement as? IrDeclarationParent
|
||||
?: (containerScope?.irElement as? IrDeclaration)?.parent
|
||||
|
||||
val inliner = Inliner(expression, actualCallee, currentScope ?: containerScope!!, parent, context)
|
||||
val inliner = Inliner(expression, actualCallee, target, currentScope ?: containerScope!!, parent, context)
|
||||
return inliner.inline().markAsRegenerated()
|
||||
}
|
||||
|
||||
@@ -157,6 +158,7 @@ class FunctionInlining(
|
||||
private inner class Inliner(
|
||||
val callSite: IrFunctionAccessExpression,
|
||||
val callee: IrFunction,
|
||||
val originalCallee: IrFunction,
|
||||
val currentScope: ScopeWithIr,
|
||||
val parent: IrDeclarationParent?,
|
||||
val context: CommonBackendContext
|
||||
@@ -176,7 +178,7 @@ class FunctionInlining(
|
||||
|
||||
val substituteMap = mutableMapOf<IrValueParameter, IrExpression>()
|
||||
|
||||
fun inline() = inlineFunction(callSite, callee, inlineFunctionResolver.getFunctionSymbol(callee).owner, true)
|
||||
fun inline() = inlineFunction(callSite, callee, originalCallee, true)
|
||||
|
||||
private fun <E : IrElement> E.copy(): E {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
||||
+1
-1
@@ -282,7 +282,7 @@ internal val functionInliningPhase = makeIrModulePhase(
|
||||
{ context ->
|
||||
class JvmInlineFunctionResolver : InlineFunctionResolver {
|
||||
override fun getFunctionDeclaration(symbol: IrFunctionSymbol): IrFunction {
|
||||
return (symbol.owner as? IrSimpleFunction)?.resolveFakeOverride() ?: symbol.owner
|
||||
return symbol.owner
|
||||
}
|
||||
|
||||
override fun getFunctionSymbol(irFunction: IrFunction): IrFunctionSymbol {
|
||||
|
||||
+1
-3
@@ -1,11 +1,9 @@
|
||||
// IGNORE_BACKEND: WASM
|
||||
// WASM_MUTE_REASON: STDLIB_ASSERT
|
||||
// https://youtrack.jetbrains.com/issue/KT-59059/Native-Assert-does-not-evaluate-argument-value-when-disabled
|
||||
// https://youtrack.jetbrains.com/issue/KT-64868/K-N-Inlined-assert-is-later-not-removed-even-without-ea
|
||||
// IGNORE_NATIVE: cacheMode=NO
|
||||
// IGNORE_BACKEND: JS_IR
|
||||
// IGNORE_BACKEND: JS_IR_ES6
|
||||
// IGNORE_BACKEND: JS
|
||||
// See related issue: https://youtrack.jetbrains.com/issue/KT-59059/Native-Assert-does-not-evaluate-argument-value-when-disabled
|
||||
// ASSERTIONS_MODE: always-disable
|
||||
// WITH_STDLIB
|
||||
|
||||
|
||||
Reference in New Issue
Block a user