FIR: Ensure that the array set argument (on RHS of =) is always mapped
to the last parameter of the set operator function, even if there are missing or too many index arguments.
This commit is contained in:
committed by
teamcityserver
parent
2bb3e94ef7
commit
34e6459014
+6
@@ -4437,6 +4437,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
||||
runTest("compiler/testData/diagnostics/tests/checkArguments/arrayAccessSet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("arrayAccessSetNotEnoughArgs.kt")
|
||||
public void testArrayAccessSetNotEnoughArgs() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/checkArguments/arrayAccessSetNotEnoughArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("arrayAccessSetTooManyArgs.kt")
|
||||
public void testArrayAccessSetTooManyArgs() throws Exception {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
operator fun get(a: Int, b: String): Boolean = true
|
||||
}
|
||||
|
||||
fun call(c: C) {
|
||||
val res = <expr>c[1, "foo"]</expr>
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
KtFunctionCall:
|
||||
argumentMapping = { 1 -> (a: kotlin.Int), "foo" -> (b: kotlin.String) }
|
||||
targetFunction = /C.get(a: kotlin.Int, b: kotlin.String): kotlin.Boolean
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
operator fun get(a: Int, b: String): Boolean = true
|
||||
}
|
||||
|
||||
fun call(c: C) {
|
||||
val res = <expr>c[1]</expr>
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
KtFunctionCall:
|
||||
argumentMapping = { 1 -> (a: kotlin.Int) }
|
||||
targetFunction = ERR<No value passed for parameter 'b', [/C.get(a: kotlin.Int, b: kotlin.String): kotlin.Boolean]>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
operator fun get(a: Int, b: String): Boolean = true
|
||||
}
|
||||
|
||||
fun call(c: C) {
|
||||
val res = <expr>c[1, "foo", false]</expr>
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
KtFunctionCall:
|
||||
argumentMapping = { 1 -> (a: kotlin.Int), "foo" -> (b: kotlin.String) }
|
||||
targetFunction = ERR<Too many arguments for public final operator fun /C.get(a: R|kotlin/Int|, b: R|kotlin/String|): R|kotlin/Boolean|, [/C.get(a: kotlin.Int, b: kotlin.String): kotlin.Boolean]>
|
||||
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
operator fun set(a: Int, b: String, value: Boolean) {}
|
||||
}
|
||||
|
||||
fun call(c: C) {
|
||||
<expr>c[1, "foo"]</expr> = false
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
KtFunctionCall:
|
||||
argumentMapping = { 1 -> (a: kotlin.Int), "foo" -> (b: kotlin.String), false -> (value: kotlin.Boolean) }
|
||||
targetFunction = /C.set(a: kotlin.Int, b: kotlin.String, value: kotlin.Boolean): kotlin.Unit
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
operator fun set(a: Int, b: String, value: Boolean) {}
|
||||
}
|
||||
|
||||
fun call(c: C) {
|
||||
<expr>c[1]</expr> = false
|
||||
}
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
KtFunctionCall:
|
||||
argumentMapping = { 1 -> (a: kotlin.Int), false -> (value: kotlin.Boolean) }
|
||||
targetFunction = ERR<No value passed for parameter 'b', [/C.set(a: kotlin.Int, b: kotlin.String, value: kotlin.Boolean): kotlin.Unit]>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class C {
|
||||
operator fun set(a: Int, b: String, value: Boolean) {}
|
||||
}
|
||||
|
||||
fun call(c: C) {
|
||||
<expr>c[1, "foo", 3.14]</expr> = false
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
KtFunctionCall:
|
||||
argumentMapping = { 1 -> (a: kotlin.Int), "foo" -> (b: kotlin.String), false -> (value: kotlin.Boolean) }
|
||||
targetFunction = ERR<Too many arguments for public final operator fun /C.set(a: R|kotlin/Int|, b: R|kotlin/String|, value: R|kotlin/Boolean|): R|kotlin/Unit|, [/C.set(a: kotlin.Int, b: kotlin.String, value: kotlin.Boolean): kotlin.Unit]>
|
||||
+2
-1
@@ -45,8 +45,9 @@ abstract class AbstractResolveCallTest : AbstractHLApiSingleModuleTest() {
|
||||
is KtCallElement -> element.resolveCall()
|
||||
is KtBinaryExpression -> element.resolveCall()
|
||||
is KtUnaryExpression -> element.resolveCall()
|
||||
is KtArrayAccessExpression -> element.resolveCall()
|
||||
is KtValueArgument -> resolveCall(element.getArgumentExpression()!!)
|
||||
else -> error("Selected should be either KtCallElement, KtBinaryExpression, or KtUnaryExpression, but was $element")
|
||||
else -> error("Selected element type (${element::class.simpleName}) is not supported for resolveCall()")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+36
@@ -114,6 +114,42 @@ public class ResolveCallTestGenerated extends AbstractResolveCallTest {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/implicitJavaConstuctorCall.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("indexedGet.kt")
|
||||
public void testIndexedGet() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/indexedGet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("indexedGetWithNotEnoughArgs.kt")
|
||||
public void testIndexedGetWithNotEnoughArgs() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/indexedGetWithNotEnoughArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("indexedGetWithTooManyArgs.kt")
|
||||
public void testIndexedGetWithTooManyArgs() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/indexedGetWithTooManyArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("indexedSet.kt")
|
||||
public void testIndexedSet() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/indexedSet.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("indexedSetWithNotEnoughArgs.kt")
|
||||
public void testIndexedSetWithNotEnoughArgs() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/indexedSetWithNotEnoughArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("indexedSetWithTooManyArgs.kt")
|
||||
public void testIndexedSetWithTooManyArgs() throws Exception {
|
||||
runTest("idea/idea-frontend-fir/testData/analysisSession/resolveCall/indexedSetWithTooManyArgs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaFunctionCall.kt")
|
||||
public void testJavaFunctionCall() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user