[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
|
val currentParameter = currentParameter ?: return MappingStatus.ERROR
|
||||||
argumentMap[argument] = currentParameter
|
argumentMap[argument] = currentParameter
|
||||||
if (!currentParameter.isVararg ||
|
|
||||||
argument is FirWrappedArgumentExpression && argument.isSpread
|
val isSpread = argument is FirWrappedArgumentExpression && argument.isSpread
|
||||||
) {
|
if (!currentParameter.isVararg || isSpread) {
|
||||||
usedParameters += currentParameter
|
usedParameters += currentParameter
|
||||||
currentParameterIndex++
|
currentParameterIndex++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!currentParameter.isVararg && isSpread) {
|
||||||
|
return MappingStatus.ERROR
|
||||||
|
}
|
||||||
|
|
||||||
return MappingStatus.SUCCESS
|
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");
|
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")
|
@TestMetadata("syntheticsVsNormalProperties.kt")
|
||||||
public void testSyntheticsVsNormalProperties() throws Exception {
|
public void testSyntheticsVsNormalProperties() throws Exception {
|
||||||
runTest("compiler/fir/resolve/testData/resolve/syntheticsVsNormalProperties.kt");
|
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");
|
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")
|
@TestMetadata("syntheticsVsNormalProperties.kt")
|
||||||
public void testSyntheticsVsNormalProperties() throws Exception {
|
public void testSyntheticsVsNormalProperties() throws Exception {
|
||||||
runTest("compiler/fir/resolve/testData/resolve/syntheticsVsNormalProperties.kt");
|
runTest("compiler/fir/resolve/testData/resolve/syntheticsVsNormalProperties.kt");
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ fun main() {
|
|||||||
join(1)
|
join(1)
|
||||||
join(1, "2")
|
join(1, "2")
|
||||||
join(1, "2", "3")
|
join(1, "2", "3")
|
||||||
join(*1, "2")
|
<!INAPPLICABLE_CANDIDATE!>join<!>(*1, "2")
|
||||||
<!INAPPLICABLE_CANDIDATE!>join<!>(1, *"2")
|
<!INAPPLICABLE_CANDIDATE!>join<!>(1, *"2")
|
||||||
join(x = 1, a = "2")
|
join(x = 1, a = "2")
|
||||||
<!INAPPLICABLE_CANDIDATE!>join<!>(x = *1, a = *"2")
|
<!INAPPLICABLE_CANDIDATE!>join<!>(x = *1, a = *"2")
|
||||||
@@ -30,7 +30,7 @@ fun main() {
|
|||||||
<!INAPPLICABLE_CANDIDATE!>join<!>(a = a, x = 1)
|
<!INAPPLICABLE_CANDIDATE!>join<!>(a = a, x = 1)
|
||||||
|
|
||||||
joinG<String>(1, "2")
|
joinG<String>(1, "2")
|
||||||
joinG<String>(*1, "2")
|
<!INAPPLICABLE_CANDIDATE!>joinG<!><String>(*1, "2")
|
||||||
<!INAPPLICABLE_CANDIDATE!>joinG<!><String>(1, *"2")
|
<!INAPPLICABLE_CANDIDATE!>joinG<!><String>(1, *"2")
|
||||||
<!INAPPLICABLE_CANDIDATE!>joinG<!><String>(x = 1, a = a)
|
<!INAPPLICABLE_CANDIDATE!>joinG<!><String>(x = 1, a = a)
|
||||||
joinG<String>(x = 1, a = "2")
|
joinG<String>(x = 1, a = "2")
|
||||||
@@ -43,7 +43,7 @@ fun main() {
|
|||||||
<!INAPPLICABLE_CANDIDATE!>joinG<!><String>(a = a, x = 1)
|
<!INAPPLICABLE_CANDIDATE!>joinG<!><String>(a = a, x = 1)
|
||||||
|
|
||||||
joinG(1, "2")
|
joinG(1, "2")
|
||||||
joinG(*1, "2")
|
<!INAPPLICABLE_CANDIDATE!>joinG<!>(*1, "2")
|
||||||
<!INAPPLICABLE_CANDIDATE!>joinG<!>(1, *"2")
|
<!INAPPLICABLE_CANDIDATE!>joinG<!>(1, *"2")
|
||||||
joinG(x = 1, a = a)
|
joinG(x = 1, a = a)
|
||||||
joinG(x = 1, a = "2")
|
joinG(x = 1, a = "2")
|
||||||
@@ -57,8 +57,8 @@ fun main() {
|
|||||||
|
|
||||||
val x1 = joinT(1, "2")
|
val x1 = joinT(1, "2")
|
||||||
checkSubtype<String?>(x1)
|
checkSubtype<String?>(x1)
|
||||||
val x2 = joinT(*1, "2")
|
val x2 = <!INAPPLICABLE_CANDIDATE!>joinT<!>(*1, "2")
|
||||||
checkSubtype<String?>(x2)
|
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><String?>(x2)
|
||||||
val x6 = joinT(1, *a)
|
val x6 = joinT(1, *a)
|
||||||
checkSubtype<String?>(x6)
|
checkSubtype<String?>(x6)
|
||||||
val x7 = <!INAPPLICABLE_CANDIDATE!>joinT<!>(1, *a, "3")
|
val x7 = <!INAPPLICABLE_CANDIDATE!>joinT<!>(1, *a, "3")
|
||||||
|
|||||||
Reference in New Issue
Block a user