Psi2ir: fix parameter indices when generating extension invoke call
Incorrect `valueParameter` was passed to `generateValueArgument`, which resulted in incorrect type being considered for generating suspend conversion. #KT-50949 Fixed
This commit is contained in:
+6
@@ -46301,6 +46301,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt50949_suspendConversionForExtensionFunction.kt")
|
||||
public void testKt50949_suspendConversionForExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/kt50949_suspendConversionForExtensionFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overloadResolutionBySuspendModifier.kt")
|
||||
public void testOverloadResolutionBySuspendModifier() throws Exception {
|
||||
|
||||
Generated
+6
@@ -1892,6 +1892,12 @@ public class Fir2IrTextTestGenerated extends AbstractFir2IrTextTest {
|
||||
runTest("compiler/testData/ir/irText/expressions/stringTemplates.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendConversionForExtensionFunction.kt")
|
||||
public void testSuspendConversionForExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/expressions/suspendConversionForExtensionFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendConversionInVararg.kt")
|
||||
public void testSuspendConversionInVararg() throws Exception {
|
||||
|
||||
+3
-3
@@ -578,9 +578,9 @@ fun StatementGenerator.pregenerateExtensionInvokeCall(resolvedCall: ResolvedCall
|
||||
ExtensionInvokeCallReceiver(call, functionReceiverValue, extensionInvokeReceiverValue)
|
||||
|
||||
call.irValueArgumentsByIndex[0] = null
|
||||
resolvedCall.valueArgumentsByIndex!!.forEachIndexed { index, valueArgument ->
|
||||
val valueParameter = call.descriptor.valueParameters[index]
|
||||
call.irValueArgumentsByIndex[index + 1] = generateValueArgument(valueArgument, valueParameter, resolvedCall)
|
||||
for ((valueParameter, valueArgument) in resolvedCall.valueArguments) {
|
||||
call.irValueArgumentsByIndex[valueParameter.index + 1] =
|
||||
generateValueArgument(valueArgument, valueParameter, resolvedCall)
|
||||
}
|
||||
|
||||
return call
|
||||
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
// IGNORE_BACKEND: JVM
|
||||
|
||||
fun box(): String {
|
||||
val foo: String.(suspend () -> Unit) -> String = { this }
|
||||
val f: () -> Unit = {}
|
||||
return "OK".foo(f)
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
FILE fqName:<root> fileName:/suspendConversionForExtensionFunction.kt
|
||||
FUN name:main visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
VAR name:foo type:@[ExtensionFunctionType] kotlin.Function2<kotlin.String, kotlin.coroutines.SuspendFunction0<kotlin.Unit>, kotlin.Unit> [val]
|
||||
FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function2<kotlin.String, kotlin.coroutines.SuspendFunction0<kotlin.Unit>, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.String, it:kotlin.coroutines.SuspendFunction0<kotlin.Unit>) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:<this> type:kotlin.String
|
||||
VALUE_PARAMETER name:it index:0 type:kotlin.coroutines.SuspendFunction0<kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (it: kotlin.coroutines.SuspendFunction0<kotlin.Unit>): kotlin.Unit declared in <root>.main'
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
VAR name:f type:kotlin.Function0<kotlin.Unit> [val]
|
||||
FUN_EXPR type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Unit declared in <root>.main'
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
CALL 'public abstract fun invoke (p1: P1 of kotlin.Function2, p2: P2 of kotlin.Function2): R of kotlin.Function2 [operator] declared in kotlin.Function2' type=kotlin.Unit origin=INVOKE
|
||||
$this: GET_VAR 'val foo: @[ExtensionFunctionType] kotlin.Function2<kotlin.String, kotlin.coroutines.SuspendFunction0<kotlin.Unit>, kotlin.Unit> [val] declared in <root>.main' type=@[ExtensionFunctionType] kotlin.Function2<kotlin.String, kotlin.coroutines.SuspendFunction0<kotlin.Unit>, kotlin.Unit> origin=VARIABLE_AS_FUNCTION
|
||||
p1: CONST String type=kotlin.String value=""
|
||||
p2: BLOCK type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=SUSPEND_CONVERSION
|
||||
FUN ADAPTER_FOR_SUSPEND_CONVERSION name:suspendConversion visibility:local modality:FINAL <> ($receiver:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit [suspend]
|
||||
$receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION name:callee type:kotlin.Function0<kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR 'callee: kotlin.Function0<kotlin.Unit> declared in <root>.main.suspendConversion' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
FUNCTION_REFERENCE 'local final fun suspendConversion (): kotlin.Unit [suspend] declared in <root>.main' type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=SUSPEND_CONVERSION reflectionTarget=null
|
||||
$receiver: GET_VAR 'val f: kotlin.Function0<kotlin.Unit> [val] declared in <root>.main' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
FILE fqName:<root> fileName:/suspendConversionForExtensionFunction.kt
|
||||
FUN name:main visibility:public modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
VAR name:foo type:@[ExtensionFunctionType] kotlin.Function2<kotlin.String, kotlin.coroutines.SuspendFunction0<kotlin.Unit>, kotlin.Unit> [val]
|
||||
FUN_EXPR type=@[ExtensionFunctionType] kotlin.Function2<kotlin.String, kotlin.coroutines.SuspendFunction0<kotlin.Unit>, kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> ($receiver:kotlin.String, it:kotlin.coroutines.SuspendFunction0<kotlin.Unit>) returnType:kotlin.Unit
|
||||
$receiver: VALUE_PARAMETER name:$this$null type:kotlin.String
|
||||
VALUE_PARAMETER name:it index:0 type:kotlin.coroutines.SuspendFunction0<kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (it: kotlin.coroutines.SuspendFunction0<kotlin.Unit>): kotlin.Unit declared in <root>.main'
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
VAR name:f type:kotlin.Function0<kotlin.Unit> [val]
|
||||
FUN_EXPR type=kotlin.Function0<kotlin.Unit> origin=LAMBDA
|
||||
FUN LOCAL_FUNCTION_FOR_LAMBDA name:<anonymous> visibility:local modality:FINAL <> () returnType:kotlin.Unit
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='local final fun <anonymous> (): kotlin.Unit declared in <root>.main'
|
||||
GET_OBJECT 'CLASS IR_EXTERNAL_DECLARATION_STUB OBJECT name:Unit modality:FINAL visibility:public superTypes:[kotlin.Any]' type=kotlin.Unit
|
||||
CALL 'public abstract fun invoke (p1: P1 of kotlin.Function2, p2: P2 of kotlin.Function2): R of kotlin.Function2 [operator] declared in kotlin.Function2' type=kotlin.Unit origin=INVOKE
|
||||
$this: GET_VAR 'val foo: @[ExtensionFunctionType] kotlin.Function2<kotlin.String, kotlin.coroutines.SuspendFunction0<kotlin.Unit>, kotlin.Unit> [val] declared in <root>.main' type=@[ExtensionFunctionType] kotlin.Function2<kotlin.String, kotlin.coroutines.SuspendFunction0<kotlin.Unit>, kotlin.Unit> origin=VARIABLE_AS_FUNCTION
|
||||
p1: CONST String type=kotlin.String value=""
|
||||
p2: BLOCK type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=SUSPEND_CONVERSION
|
||||
FUN ADAPTER_FOR_SUSPEND_CONVERSION name:suspendConversion0 visibility:local modality:FINAL <> ($receiver:kotlin.Function0<kotlin.Unit>) returnType:kotlin.Unit [suspend]
|
||||
$receiver: VALUE_PARAMETER ADAPTER_PARAMETER_FOR_SUSPEND_CONVERSION name:callee type:kotlin.Function0<kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
CALL 'public abstract fun invoke (): R of kotlin.Function0 [operator] declared in kotlin.Function0' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR 'callee: kotlin.Function0<kotlin.Unit> declared in <root>.main.suspendConversion0' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
FUNCTION_REFERENCE 'local final fun suspendConversion0 (): kotlin.Unit [suspend] declared in <root>.main' type=kotlin.coroutines.SuspendFunction0<kotlin.Unit> origin=SUSPEND_CONVERSION reflectionTarget=null
|
||||
$receiver: GET_VAR 'val f: kotlin.Function0<kotlin.Unit> [val] declared in <root>.main' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// SKIP_KT_DUMP
|
||||
// !LANGUAGE: +SuspendConversion
|
||||
|
||||
fun main() {
|
||||
val foo: String.(suspend () -> Unit) -> Unit = {}
|
||||
val f: () -> Unit = {}
|
||||
"".foo(f)
|
||||
}
|
||||
+6
@@ -45761,6 +45761,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt50949_suspendConversionForExtensionFunction.kt")
|
||||
public void testKt50949_suspendConversionForExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/kt50949_suspendConversionForExtensionFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overloadResolutionBySuspendModifier.kt")
|
||||
public void testOverloadResolutionBySuspendModifier() throws Exception {
|
||||
|
||||
+6
@@ -46301,6 +46301,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt50949_suspendConversionForExtensionFunction.kt")
|
||||
public void testKt50949_suspendConversionForExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/kt50949_suspendConversionForExtensionFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overloadResolutionBySuspendModifier.kt")
|
||||
public void testOverloadResolutionBySuspendModifier() throws Exception {
|
||||
|
||||
Generated
+6
@@ -1892,6 +1892,12 @@ public class IrTextTestGenerated extends AbstractIrTextTest {
|
||||
runTest("compiler/testData/ir/irText/expressions/stringTemplates.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendConversionForExtensionFunction.kt")
|
||||
public void testSuspendConversionForExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/expressions/suspendConversionForExtensionFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("suspendConversionInVararg.kt")
|
||||
public void testSuspendConversionInVararg() throws Exception {
|
||||
|
||||
+5
@@ -37065,6 +37065,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt50949_suspendConversionForExtensionFunction.kt")
|
||||
public void ignoreKt50949_suspendConversionForExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/kt50949_suspendConversionForExtensionFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overloadResolutionBySuspendModifier.kt")
|
||||
public void ignoreOverloadResolutionBySuspendModifier() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.kt");
|
||||
|
||||
@@ -1402,6 +1402,11 @@ public class KlibTextTestCaseGenerated extends AbstractKlibTextTestCase {
|
||||
runTest("compiler/testData/ir/irText/expressions/stringTemplates.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendConversionForExtensionFunction.kt")
|
||||
public void testSuspendConversionForExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/expressions/suspendConversionForExtensionFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("suspendConversionInVararg.kt")
|
||||
public void testSuspendConversionInVararg() throws Exception {
|
||||
runTest("compiler/testData/ir/irText/expressions/suspendConversionInVararg.kt");
|
||||
|
||||
+6
@@ -33577,6 +33577,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt50949_suspendConversionForExtensionFunction.kt")
|
||||
public void testKt50949_suspendConversionForExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/kt50949_suspendConversionForExtensionFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overloadResolutionBySuspendModifier.kt")
|
||||
public void testOverloadResolutionBySuspendModifier() throws Exception {
|
||||
|
||||
+6
@@ -33679,6 +33679,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt50949_suspendConversionForExtensionFunction.kt")
|
||||
public void testKt50949_suspendConversionForExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/kt50949_suspendConversionForExtensionFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overloadResolutionBySuspendModifier.kt")
|
||||
public void testOverloadResolutionBySuspendModifier() throws Exception {
|
||||
|
||||
+5
@@ -28120,6 +28120,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt50949_suspendConversionForExtensionFunction.kt")
|
||||
public void testKt50949_suspendConversionForExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/kt50949_suspendConversionForExtensionFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("overloadResolutionBySuspendModifier.kt")
|
||||
public void testOverloadResolutionBySuspendModifier() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/overloadResolutionBySuspendModifier.kt");
|
||||
|
||||
+6
@@ -36646,6 +36646,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/chainedFunSuspendConversionForSimpleExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt50949_suspendConversionForExtensionFunction.kt")
|
||||
public void testKt50949_suspendConversionForExtensionFunction() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/suspendConversion/kt50949_suspendConversionForExtensionFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("overloadResolutionBySuspendModifier.kt")
|
||||
public void testOverloadResolutionBySuspendModifier() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user