diff --git a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt index 5d3e5126481..cbf52207607 100644 --- a/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt +++ b/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/lower/inline/FunctionInlining.kt @@ -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() - fun inline() = inlineFunction(callSite, callee, inlineFunctionResolver.getFunctionSymbol(callee).owner, true) + fun inline() = inlineFunction(callSite, callee, originalCallee, true) private fun E.copy(): E { @Suppress("UNCHECKED_CAST") diff --git a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/JvmLoweringPhases.kt b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/JvmLoweringPhases.kt index 79777645270..885b662a228 100644 --- a/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/JvmLoweringPhases.kt +++ b/compiler/ir/backend.jvm/lower/src/org/jetbrains/kotlin/backend/jvm/JvmLoweringPhases.kt @@ -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 { diff --git a/compiler/testData/codegen/box/assert/alwaysDisable.kt b/compiler/testData/codegen/box/assert/alwaysDisable.kt index 73c0e2193bf..fdc3377d28b 100644 --- a/compiler/testData/codegen/box/assert/alwaysDisable.kt +++ b/compiler/testData/codegen/box/assert/alwaysDisable.kt @@ -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