Fix search usages for invoke() with vararg parameter (KT-18479)
#KT-18479 Fixed
This commit is contained in:
+1
-1
@@ -47,7 +47,7 @@ class InvokeOperatorReferenceSearcher(
|
||||
val uMethod = uastContext.convertOpt<UMethod>(targetDeclaration, null)
|
||||
val uastParameters = uMethod?.uastParameters
|
||||
|
||||
val isStableNumberOfArguments = uastParameters != null && uastParameters.none { it.uastInitializer != null }
|
||||
val isStableNumberOfArguments = uastParameters != null && uastParameters.none { it.uastInitializer != null || it.isVarArgs }
|
||||
callArgumentsSize = if (isStableNumberOfArguments) {
|
||||
val numberOfArguments = uastParameters!!.size
|
||||
when {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// PSI_ELEMENT: org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
// OPTIONS: usages
|
||||
package pack
|
||||
|
||||
class P {
|
||||
operator fun <caret>invoke(vararg i: Int) = 1
|
||||
}
|
||||
|
||||
fun f(p: P) {
|
||||
p()
|
||||
p(1, 2)
|
||||
p(1)
|
||||
p.invoke()
|
||||
p.invoke(1, 2, 3)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
Resolved p()
|
||||
Resolved p(1)
|
||||
Resolved p(1, 2)
|
||||
Searched references to pack.P
|
||||
Searched references to parameter p of pack.f(p: P) in non-Java files
|
||||
Used plain search of pack.P.invoke(vararg i: Int) in LocalSearchScope:
|
||||
CLASS:P
|
||||
@@ -0,0 +1,5 @@
|
||||
Function call 13 p.invoke()
|
||||
Function call 14 p.invoke(1, 2, 3)
|
||||
Implicit 'invoke' 10 p()
|
||||
Implicit 'invoke' 11 p(1, 2)
|
||||
Implicit 'invoke' 12 p(1)
|
||||
@@ -139,6 +139,12 @@ public class FindUsagesTestGenerated extends AbstractFindUsagesTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("invokeWithVarArg.0.kt")
|
||||
public void testInvokeWithVarArg() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/conventions/invokeWithVarArg.0.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("plus.0.kt")
|
||||
public void testPlus() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/findUsages/kotlin/conventions/plus.0.kt");
|
||||
|
||||
Reference in New Issue
Block a user