Generate inline function arguments with parameters types
#KT-44429 Fixed
This commit is contained in:
+5
@@ -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");
|
||||
|
||||
+3
-3
@@ -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() {
|
||||
|
||||
+2
-2
@@ -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)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// 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"
|
||||
}
|
||||
+5
@@ -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");
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
+5
@@ -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");
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Generated
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user