[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 ->
|
symbol == context.ir.symbols.coroutineContextGetter ->
|
||||||
context.ir.symbols.coroutineGetContext.owner
|
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))
|
if (!callee.needsInlining || inlineFunctionResolver.shouldExcludeFunctionFromInlining(callee.symbol))
|
||||||
return expression
|
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) {
|
if (actualCallee.body == null) {
|
||||||
return expression
|
return expression
|
||||||
}
|
}
|
||||||
@@ -131,7 +132,7 @@ class FunctionInlining(
|
|||||||
?: containerScope?.irElement as? IrDeclarationParent
|
?: containerScope?.irElement as? IrDeclarationParent
|
||||||
?: (containerScope?.irElement as? IrDeclaration)?.parent
|
?: (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()
|
return inliner.inline().markAsRegenerated()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,6 +158,7 @@ class FunctionInlining(
|
|||||||
private inner class Inliner(
|
private inner class Inliner(
|
||||||
val callSite: IrFunctionAccessExpression,
|
val callSite: IrFunctionAccessExpression,
|
||||||
val callee: IrFunction,
|
val callee: IrFunction,
|
||||||
|
val originalCallee: IrFunction,
|
||||||
val currentScope: ScopeWithIr,
|
val currentScope: ScopeWithIr,
|
||||||
val parent: IrDeclarationParent?,
|
val parent: IrDeclarationParent?,
|
||||||
val context: CommonBackendContext
|
val context: CommonBackendContext
|
||||||
@@ -176,7 +178,7 @@ class FunctionInlining(
|
|||||||
|
|
||||||
val substituteMap = mutableMapOf<IrValueParameter, IrExpression>()
|
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 {
|
private fun <E : IrElement> E.copy(): E {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
|||||||
+1
-1
@@ -282,7 +282,7 @@ internal val functionInliningPhase = makeIrModulePhase(
|
|||||||
{ context ->
|
{ context ->
|
||||||
class JvmInlineFunctionResolver : InlineFunctionResolver {
|
class JvmInlineFunctionResolver : InlineFunctionResolver {
|
||||||
override fun getFunctionDeclaration(symbol: IrFunctionSymbol): IrFunction {
|
override fun getFunctionDeclaration(symbol: IrFunctionSymbol): IrFunction {
|
||||||
return (symbol.owner as? IrSimpleFunction)?.resolveFakeOverride() ?: symbol.owner
|
return symbol.owner
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getFunctionSymbol(irFunction: IrFunction): IrFunctionSymbol {
|
override fun getFunctionSymbol(irFunction: IrFunction): IrFunctionSymbol {
|
||||||
|
|||||||
+1
-3
@@ -1,11 +1,9 @@
|
|||||||
// IGNORE_BACKEND: WASM
|
// IGNORE_BACKEND: WASM
|
||||||
// WASM_MUTE_REASON: STDLIB_ASSERT
|
// 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
|
||||||
// IGNORE_BACKEND: JS_IR_ES6
|
// IGNORE_BACKEND: JS_IR_ES6
|
||||||
// IGNORE_BACKEND: JS
|
// 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
|
// ASSERTIONS_MODE: always-disable
|
||||||
// WITH_STDLIB
|
// WITH_STDLIB
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user