From 66429cfb43866dcd749d3bf2f8ee59b971bd4ff5 Mon Sep 17 00:00:00 2001 From: pyos Date: Fri, 19 Mar 2021 12:10:10 +0100 Subject: [PATCH] JVM_IR: do not inline `@JvmStatic` into their static proxies --- .../jetbrains/kotlin/backend/jvm/JvmCachedDeclarations.kt | 2 -- .../kotlin/backend/jvm/codegen/ExpressionCodegen.kt | 6 ++---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmCachedDeclarations.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmCachedDeclarations.kt index 4d6dbf14592..b92dc70d16b 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmCachedDeclarations.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/JvmCachedDeclarations.kt @@ -192,8 +192,6 @@ class JvmCachedDeclarations( valueParameters = target.valueParameters.map { it.copyTo(this) } body = context.createIrBuilder(symbol).run { - // TODO: if the `@JvmStatic` function is inline, this inlines it into the proxy - not great (?) - // for something that's supposed to be only relevant for Java compatibility. irExprBody(irCall(target).apply { passTypeArgumentsFrom(this@proxy) if (target.dispatchReceiverParameter != null) { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt index f9d567fce4c..6bc7059c98f 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/ExpressionCodegen.kt @@ -460,10 +460,7 @@ class ExpressionCodegen( addSuspendMarker(mv, isStartNotEnd = true, isSuspensionPoint == SuspensionPointKind.NOT_INLINE) } - val generatorForActualCall = - // Do not inline callee to continuation, instead, call it - if (irFunction.isInvokeSuspendOfContinuation()) IrCallGenerator.DefaultCallGenerator else callGenerator - generatorForActualCall.genCall(callable, this, expression, isInsideCondition) + callGenerator.genCall(callable, this, expression, isInsideCondition) val unboxedInlineClassIrType = callee.suspendFunctionOriginal().originalReturnTypeOfSuspendFunctionReturningUnboxedInlineClass() @@ -1351,6 +1348,7 @@ class ExpressionCodegen( ): IrCallGenerator { if (!element.symbol.owner.isInlineFunctionCall(context) || classCodegen.irClass.fileParent.fileEntry is MultifileFacadeFileEntry || + irFunction.origin == JvmLoweredDeclarationOrigin.JVM_STATIC_WRAPPER || irFunction.isInvokeSuspendOfContinuation() ) { return IrCallGenerator.DefaultCallGenerator