提交 147d6052 编写于 作者: M Mikhael Bogdanov

Generate inline function arguments with parameters types

 #KT-44429 Fixed
上级 50ab9ed0
......@@ -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");
......
......@@ -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() {
......
......@@ -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)
}
......
// FILE: 1.kt
package test
inline fun <T> 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
......@@ -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");
......
......@@ -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");
......
......@@ -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");
......
......@@ -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");
......
......@@ -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");
......
......@@ -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");
......
......@@ -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");
......
......@@ -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");
......
......@@ -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");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册