Fix SAM conversion generation condition
Remove check if array is passed to vararg parameter as it's not relevant anymore and leads to ^KT-51821. ^KT-51821: Fixed
This commit is contained in:
committed by
teamcity
parent
c604577132
commit
7033d78641
+6
@@ -47661,6 +47661,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
||||
runTest("compiler/testData/codegen/box/sam/kt50477Enabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51821.kt")
|
||||
public void testKt51821() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt51821.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52417.kt")
|
||||
public void testKt52417() throws Exception {
|
||||
|
||||
+6
@@ -47661,6 +47661,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
||||
runTest("compiler/testData/codegen/box/sam/kt50477Enabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51821.kt")
|
||||
public void testKt51821() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt51821.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52417.kt")
|
||||
public void testKt52417() throws Exception {
|
||||
|
||||
+1
-5
@@ -634,10 +634,6 @@ fun StatementGenerator.generateSamConversionForValueArgumentsIfRequired(call: Ca
|
||||
"Mismatching resolved call arguments:\n" +
|
||||
"${resolvedCallArguments?.size} != ${underlyingValueParameters.size}"
|
||||
}
|
||||
val isArrayAssignedToVararg: Boolean = resolvedCallArguments != null &&
|
||||
(underlyingValueParameters zip resolvedCallArguments).any { (param, arg) ->
|
||||
param.isVararg && arg is ResolvedCallArgument.SimpleArgument && arg.callArgument.isArrayOrArrayLiteral()
|
||||
}
|
||||
|
||||
val substitutionContext = call.original.typeArguments.entries.associate { (typeParameterDescriptor, typeArgument) ->
|
||||
underlyingDescriptor.typeParameters[typeParameterDescriptor.index].typeConstructor to TypeProjectionImpl(typeArgument)
|
||||
@@ -648,7 +644,7 @@ fun StatementGenerator.generateSamConversionForValueArgumentsIfRequired(call: Ca
|
||||
val underlyingValueParameter: ValueParameterDescriptor = underlyingValueParameters[i]
|
||||
|
||||
val expectedSamConversionTypesForVararg =
|
||||
if (!isArrayAssignedToVararg && resolvedCall is NewResolvedCallImpl<*>) {
|
||||
if (resolvedCall is NewResolvedCallImpl<*>) {
|
||||
val arguments = resolvedCall.valueArguments[originalValueParameters[i]]?.arguments
|
||||
arguments?.map { resolvedCall.getExpectedTypeForSamConvertedArgument(it) }
|
||||
} else null
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fun interface A {
|
||||
fun f(x: String): String
|
||||
}
|
||||
|
||||
fun foo(a: A, vararg s: String): String =
|
||||
a.f(s[0])
|
||||
|
||||
fun bar(vararg s: String): String =
|
||||
foo({ it }, s = s)
|
||||
|
||||
fun box(): String = bar("OK")
|
||||
+6
@@ -45471,6 +45471,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/sam/kt50171.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51821.kt")
|
||||
public void testKt51821() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt51821.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52417.kt")
|
||||
public void testKt52417() throws Exception {
|
||||
|
||||
+6
@@ -47661,6 +47661,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/sam/kt50477Enabled.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51821.kt")
|
||||
public void testKt51821() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt51821.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt52417.kt")
|
||||
public void testKt52417() throws Exception {
|
||||
|
||||
+5
@@ -36716,6 +36716,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/sam/kt50171.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt51821.kt")
|
||||
public void testKt51821() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt51821.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt52417.kt")
|
||||
public void testKt52417() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt52417.kt");
|
||||
|
||||
+6
@@ -33965,6 +33965,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/sam/kt17765.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51821.kt")
|
||||
public void testKt51821() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt51821.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt56188.kt")
|
||||
public void testKt56188() throws Exception {
|
||||
|
||||
+6
@@ -34151,6 +34151,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/sam/kt17765.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51821.kt")
|
||||
public void testKt51821() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt51821.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt56188.kt")
|
||||
public void testKt56188() throws Exception {
|
||||
|
||||
+6
@@ -34151,6 +34151,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/sam/kt17765.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51821.kt")
|
||||
public void testKt51821() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt51821.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt56188.kt")
|
||||
public void testKt56188() throws Exception {
|
||||
|
||||
+6
@@ -34151,6 +34151,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
|
||||
runTest("compiler/testData/codegen/box/sam/kt17765.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51821.kt")
|
||||
public void testKt51821() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt51821.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt56188.kt")
|
||||
public void testKt56188() throws Exception {
|
||||
|
||||
+6
@@ -37692,6 +37692,12 @@ public class K2NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTes
|
||||
runTest("compiler/testData/codegen/box/sam/kt17765.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51821.kt")
|
||||
public void testKt51821() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt51821.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt56188.kt")
|
||||
public void testKt56188() throws Exception {
|
||||
|
||||
+6
@@ -37226,6 +37226,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
runTest("compiler/testData/codegen/box/sam/kt17765.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt51821.kt")
|
||||
public void testKt51821() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt51821.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kt56188.kt")
|
||||
public void testKt56188() throws Exception {
|
||||
|
||||
Generated
+5
@@ -30566,6 +30566,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/sam/kt17765.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt51821.kt")
|
||||
public void testKt51821() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt51821.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt56188.kt")
|
||||
public void testKt56188() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/sam/kt56188.kt");
|
||||
|
||||
Reference in New Issue
Block a user