[FIR] Discard argument with spread in place of non-vararg parameter
This commit is contained in:
+7
-3
@@ -69,13 +69,17 @@ class FirCallArgumentsProcessor(
|
||||
|
||||
val currentParameter = currentParameter ?: return MappingStatus.ERROR
|
||||
argumentMap[argument] = currentParameter
|
||||
if (!currentParameter.isVararg ||
|
||||
argument is FirWrappedArgumentExpression && argument.isSpread
|
||||
) {
|
||||
|
||||
val isSpread = argument is FirWrappedArgumentExpression && argument.isSpread
|
||||
if (!currentParameter.isVararg || isSpread) {
|
||||
usedParameters += currentParameter
|
||||
currentParameterIndex++
|
||||
}
|
||||
|
||||
if (!currentParameter.isVararg && isSpread) {
|
||||
return MappingStatus.ERROR
|
||||
}
|
||||
|
||||
return MappingStatus.SUCCESS
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
// FILE: Utils.java
|
||||
|
||||
public class Utils {
|
||||
public static String[] getStrings() {
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: Main.kt
|
||||
|
||||
fun <T> myListOf(vararg elements: T): List<T> = null!!
|
||||
fun <T> myListOf(element: T): List<T> = null!!
|
||||
|
||||
fun takeStrings(list: List<String>) {}
|
||||
|
||||
fun getStrings(): Array<String> = null!!
|
||||
|
||||
fun testFromKotlin() {
|
||||
val values = getStrings()
|
||||
val list = myListOf(*values)
|
||||
takeStrings(list)
|
||||
}
|
||||
|
||||
fun testFromJava() {
|
||||
val values = Utils.getStrings()
|
||||
val list = myListOf(*values)
|
||||
takeStrings(list)
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
FILE: Main.kt
|
||||
public final fun <T> myListOf(vararg elements: R|kotlin/Array<T>|): R|kotlin/collections/List<T>| {
|
||||
^myListOf Null(null)!!
|
||||
}
|
||||
public final fun <T> myListOf(element: R|T|): R|kotlin/collections/List<T>| {
|
||||
^myListOf Null(null)!!
|
||||
}
|
||||
public final fun takeStrings(list: R|kotlin/collections/List<kotlin/String>|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun getStrings(): R|kotlin/Array<kotlin/String>| {
|
||||
^getStrings Null(null)!!
|
||||
}
|
||||
public final fun testFromKotlin(): R|kotlin/Unit| {
|
||||
lval values: R|kotlin/Array<kotlin/String>| = R|/getStrings|()
|
||||
lval list: R|kotlin/collections/List<kotlin/String>| = R|/myListOf|<R|kotlin/String|>(vararg(*R|<local>/values|))
|
||||
R|/takeStrings|(R|<local>/list|)
|
||||
}
|
||||
public final fun testFromJava(): R|kotlin/Unit| {
|
||||
lval values: R|ft<kotlin/Array<ft<kotlin/String, kotlin/String?>!>, kotlin/Array<out ft<kotlin/String, kotlin/String?>!>?>!| = Q|Utils|.R|/Utils.getStrings|()
|
||||
lval list: R|kotlin/collections/List<ft<kotlin/String, kotlin/String?>!>| = R|/myListOf|<R|ft<kotlin/String, kotlin/String?>!|>(vararg(*R|<local>/values|))
|
||||
R|/takeStrings|(R|<local>/list|)
|
||||
}
|
||||
+5
@@ -268,6 +268,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/resolve/testData/resolve/simpleTypeAlias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("spreadOperator.kt")
|
||||
public void testSpreadOperator() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/spreadOperator.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticsVsNormalProperties.kt")
|
||||
public void testSyntheticsVsNormalProperties() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/syntheticsVsNormalProperties.kt");
|
||||
|
||||
Generated
+5
@@ -268,6 +268,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/resolve/testData/resolve/simpleTypeAlias.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("spreadOperator.kt")
|
||||
public void testSpreadOperator() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/spreadOperator.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("syntheticsVsNormalProperties.kt")
|
||||
public void testSyntheticsVsNormalProperties() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/syntheticsVsNormalProperties.kt");
|
||||
|
||||
Reference in New Issue
Block a user