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");
|
||||
|
||||
Reference in New Issue
Block a user