diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java index 106e47b9d0e..735807fe896 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/codegen/ir/FirBlackBoxInlineCodegenTestGenerated.java @@ -1099,6 +1099,11 @@ public class FirBlackBoxInlineCodegenTestGenerated extends AbstractFirBlackBoxIn runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); 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 e81ea9f9a90..e461e454fbf 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 @@ -198,13 +198,13 @@ class ExpressionCodegen( return StackValue.onStack(type, irType.toIrBasedKotlinType()) } - internal fun genOrGetLocal(expression: IrExpression, data: BlockInfo): StackValue { + internal fun genOrGetLocal(expression: IrExpression, type: Type, parameterType: IrType, data: BlockInfo): StackValue { if (irFunction.origin == IrDeclarationOrigin.FUNCTION_FOR_DEFAULT_PARAMETER) { if (expression is IrTypeOperatorCall && expression.operator == IrTypeOperator.IMPLICIT_CAST) { // inline lambda parameters are passed from `foo$default` to `foo` call with implicit cast, // we need return pure StackValue.local value to be able proper inline this parameter later if (expression.type.makeNullable() == expression.argument.type) { - return genOrGetLocal(expression.argument, data) + return genOrGetLocal(expression.argument, type, parameterType, data) } } } @@ -212,7 +212,7 @@ class ExpressionCodegen( return if (expression is IrGetValue) StackValue.local(findLocalIndex(expression.symbol), frameMap.typeOf(expression.symbol), expression.type.toIrBasedKotlinType()) else - gen(expression, typeMapper.mapType(expression.type), expression.type, data) + gen(expression, type, parameterType, data) } fun generate() { diff --git a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt index 7a3212d9e24..8cf6c637b0b 100644 --- a/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt +++ b/compiler/ir/backend.jvm/src/org/jetbrains/kotlin/backend/jvm/codegen/IrInlineCodegen.kt @@ -110,7 +110,7 @@ class IrInlineCodegen( // Reuse an existing local if possible. NOTE: when stopping at a breakpoint placed // in an inline function, arguments which reuse an existing local will not be visible // in the debugger. - -> codegen.genOrGetLocal(argumentExpression, blockInfo) + -> codegen.genOrGetLocal(argumentExpression, parameterType, irValueParameter.type, blockInfo) else // Do not reuse locals for receivers. While it's actually completely fine, the non-IR // backend does not do it for internal reasons, and here we replicate the debugging @@ -128,7 +128,7 @@ class IrInlineCodegen( } private fun putCapturedValueOnStack(argumentExpression: IrExpression, valueType: Type, capturedParamIndex: Int) { - val onStack = codegen.genOrGetLocal(argumentExpression, BlockInfo()) + val onStack = codegen.genOrGetLocal(argumentExpression, valueType, argumentExpression.type, BlockInfo()) val expectedType = JvmKotlinType(valueType, argumentExpression.type.toIrBasedKotlinType()) putArgumentOrCapturedToLocalVal(expectedType, onStack, capturedParamIndex, capturedParamIndex, ValueKind.CAPTURED) } diff --git a/compiler/testData/codegen/boxInline/complex/kt44429.kt b/compiler/testData/codegen/boxInline/complex/kt44429.kt new file mode 100644 index 00000000000..4e3b2dfde39 --- /dev/null +++ b/compiler/testData/codegen/boxInline/complex/kt44429.kt @@ -0,0 +1,13 @@ +// FILE: 1.kt +package test + +inline fun takeT(t: T) {} + +// FILE: 2.kt +import test.* + +fun box(): String { + val f = { null } as () -> Int + takeT(f()) + return "OK" +} \ No newline at end of file diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index c79d66772ad..08768c1d393 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -1099,6 +1099,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index 53008f9e117..cdc6c658f5b 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -1099,6 +1099,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index 3c42ebbeebc..a63eb5652e1 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -1099,6 +1099,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java index b96c4df39fe..057a0ec17ef 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/IrCompileKotlinAgainstInlineKotlinTestGenerated.java @@ -1099,6 +1099,11 @@ public class IrCompileKotlinAgainstInlineKotlinTestGenerated extends AbstractIrC runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java index 9f91c2e3c1c..e53ac975c9e 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmIrAgainstOldBoxInlineTestGenerated.java @@ -1099,6 +1099,11 @@ public class JvmIrAgainstOldBoxInlineTestGenerated extends AbstractJvmIrAgainstO runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java index 22c4b5bc1cd..0833aee391a 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/ir/JvmOldAgainstIrBoxInlineTestGenerated.java @@ -1099,6 +1099,11 @@ public class JvmOldAgainstIrBoxInlineTestGenerated extends AbstractJvmOldAgainst runTest("compiler/testData/codegen/boxInline/complex/forEachLine.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("lambdaInLambda.kt") public void testLambdaInLambda() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/lambdaInLambda.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java index baf319def9c..588bcf36a64 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenInlineES6TestGenerated.java @@ -949,6 +949,11 @@ public class IrJsCodegenInlineES6TestGenerated extends AbstractIrJsCodegenInline runTest("compiler/testData/codegen/boxInline/complex/closureChain.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("swapAndWith.kt") public void testSwapAndWith() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/swapAndWith.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java index 3ae0f317bbf..4e068f7f7f6 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenInlineTestGenerated.java @@ -949,6 +949,11 @@ public class IrJsCodegenInlineTestGenerated extends AbstractIrJsCodegenInlineTes runTest("compiler/testData/codegen/boxInline/complex/closureChain.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("swapAndWith.kt") public void testSwapAndWith() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/swapAndWith.kt"); diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java index 1453d0bc88d..e928f203178 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/semantics/JsCodegenInlineTestGenerated.java @@ -949,6 +949,11 @@ public class JsCodegenInlineTestGenerated extends AbstractJsCodegenInlineTest { runTest("compiler/testData/codegen/boxInline/complex/closureChain.kt"); } + @TestMetadata("kt44429.kt") + public void testKt44429() throws Exception { + runTest("compiler/testData/codegen/boxInline/complex/kt44429.kt"); + } + @TestMetadata("swapAndWith.kt") public void testSwapAndWith() throws Exception { runTest("compiler/testData/codegen/boxInline/complex/swapAndWith.kt");