Analysis API: Handle other FirElements in

KtCallResolver.resolveCandidates() and copy over remaining tests.
This commit is contained in:
Mark Punzalan
2022-01-31 17:58:37 +00:00
committed by Ilya Kirillov
parent 9b9da94a09
commit 58c6c25fe9
107 changed files with 1736 additions and 38 deletions
@@ -84,7 +84,28 @@ internal class KtFirCallResolver(
}
override fun resolveCall(psi: KtElement): KtCallInfo? = withValidityAssertion {
if (psi.isNotResolvable()) return null
val ktCallInfos = getKtCallInfos(psi) { psiToResolve, resolveCalleeExpressionOfFunctionCall, resolveFragmentOfCall ->
listOfNotNull(
toKtCallInfo(
psiToResolve,
resolveCalleeExpressionOfFunctionCall,
resolveFragmentOfCall
)
)
}
check(ktCallInfos.size <= 1) { "Should only return 1 KtCallInfo" }
return ktCallInfos.singleOrNull()
}
private inline fun getKtCallInfos(
psi: KtElement,
getKtCallInfos: FirElement.(
psiToResolve: KtElement,
resolveCalleeExpressionOfFunctionCall: Boolean,
resolveFragmentOfCall: Boolean
) -> List<KtCallInfo>
): List<KtCallInfo> {
if (psi.isNotResolvable()) return emptyList()
val containingCallExpressionForCalleeExpression = psi.getContainingCallExpressionForCalleeExpression()
val containingBinaryExpressionForLhs = psi.getContainingBinaryExpressionForIncompleteLhs()
@@ -94,11 +115,11 @@ internal class KtFirCallResolver(
?: containingBinaryExpressionForLhs
?: containingUnaryExpressionForIncOrDec
?: psi
val fir = psiToResolve.getOrBuildFir(analysisSession.firResolveState) ?: return null
fir.toKtCallInfo(
val fir = psiToResolve.getOrBuildFir(analysisSession.firResolveState) ?: return emptyList()
return fir.getKtCallInfos(
psiToResolve,
resolveCalleeExpressionOfFunctionCall = psiToResolve == containingCallExpressionForCalleeExpression,
resolveFragmentOfCall = psiToResolve == containingBinaryExpressionForLhs || psiToResolve == containingUnaryExpressionForIncOrDec
psiToResolve == containingCallExpressionForCalleeExpression,
psiToResolve == containingBinaryExpressionForLhs || psiToResolve == containingUnaryExpressionForIncOrDec
)
}
@@ -678,14 +699,62 @@ internal class KtFirCallResolver(
firSymbolBuilder.variableLikeBuilder.buildValueParameterSymbol(this)
override fun resolveCandidates(psi: KtElement): List<KtCallInfo> = withValidityAssertion {
val firCall = when (val fir = psi.getOrBuildFir(firResolveState)) {
is FirFunctionCall -> fir
is FirSafeCallExpression -> fir.selector.safeAs<FirFunctionCall>()
// TODO: FirDelegatedConstructorColl, FirAnnotationCall, FirArrayOfCall, FirConstructor
else -> null
} ?: return@withValidityAssertion emptyList()
val firFile = psi.containingKtFile.getOrBuildFirFile(firResolveState)
AllCandidatesResolver(analysisSession.rootModuleSession, firFile).getAllCandidates(firCall, psi)
getKtCallInfos(psi) { psiToResolve, resolveCalleeExpressionOfFunctionCall, resolveFragmentOfCall ->
resolveCandidates(
psiToResolve,
resolveCalleeExpressionOfFunctionCall,
resolveFragmentOfCall
)
}
}
// TODO: Refactor common code with FirElement.toKtCallInfo() when other FirResolvables are handled
private fun FirElement.resolveCandidates(
psi: KtElement,
resolveCalleeExpressionOfFunctionCall: Boolean,
resolveFragmentOfCall: Boolean,
): List<KtCallInfo> {
if (this is FirCheckNotNullCall)
return listOf(KtSuccessCallInfo(KtCheckNotNullCall(token, argumentList.arguments.first().psi as KtExpression)))
if (resolveCalleeExpressionOfFunctionCall && this is FirImplicitInvokeCall) {
// For implicit invoke, we resolve the calleeExpression of the CallExpression to the call that creates the receiver of this
// implicit invoke call. For example,
// ```
// fun test(f: () -> Unit) {
// f() // calleeExpression `f` resolves to the local variable access, while `f()` resolves to the implicit `invoke` call.
// // This way `f` is also the explicit receiver of this implicit `invoke` call
// }
// ```
return explicitReceiver?.resolveCandidates(
psi,
resolveCalleeExpressionOfFunctionCall = false,
resolveFragmentOfCall = resolveFragmentOfCall
) ?: emptyList()
}
return when (this) {
is FirFunctionCall -> {
val firFile = psi.containingKtFile.getOrBuildFirFile(firResolveState)
AllCandidatesResolver(analysisSession.rootModuleSession, firFile).getAllCandidates(this, psi, resolveFragmentOfCall)
}
is FirSafeCallExpression -> selector.resolveCandidates(
psi,
resolveCalleeExpressionOfFunctionCall,
resolveFragmentOfCall
)
is FirArrayOfCall, is FirComparisonExpression, is FirEqualityOperatorCall -> {
listOfNotNull(
toKtCallInfo(
psi,
resolveCalleeExpressionOfFunctionCall,
resolveFragmentOfCall
)
)
}
else -> {
// TODO: FirDelegatedConstructorCall, FirAnnotationCall, FirPropertyAccessExpression, FirVariableAssignment
listOf()
}
}
}
private inner class AllCandidatesResolver(private val firSession: FirSession, private val firFile: FirFile) {
@@ -709,7 +778,7 @@ internal class KtFirCallResolver(
private val resolutionContext = ResolutionContext(firSession, bodyResolveComponents, stubBodyResolveTransformer.context)
fun getAllCandidates(functionCall: FirFunctionCall, element: KtElement): List<KtCallInfo> {
fun getAllCandidates(functionCall: FirFunctionCall, element: KtElement, resolveFragmentOfCall: Boolean): List<KtCallInfo> {
initializeBodyResolveContext(element)
// If a function call is resolved to an implicit invoke call, the FirImplicitInvokeCall will have the `invoke()` function as the
@@ -740,7 +809,15 @@ internal class KtFirCallResolver(
resolutionContext
)
}
return candidates.mapNotNull { convertToKtCallInfo(originalFunctionCall, element, it.candidate, it.isInBestCandidates) }
return candidates.mapNotNull {
convertToKtCallInfo(
originalFunctionCall,
element,
it.candidate,
it.isInBestCandidates,
resolveFragmentOfCall
)
}
}
@OptIn(PrivateForInline::class, SymbolInternals::class)
@@ -757,9 +834,10 @@ internal class KtFirCallResolver(
functionCall: FirFunctionCall,
element: KtElement,
candidate: Candidate,
isInBestCandidates: Boolean
isInBestCandidates: Boolean,
resolveFragmentOfCall: Boolean
): KtCallInfo? {
val call = createKtCall(element, functionCall, candidate, resolveFragmentOfCall = false) // TODO: resolveFragmentOfCall
val call = createKtCall(element, functionCall, candidate, resolveFragmentOfCall)
?: error("expect `createKtCall` to succeed for candidate")
return if (candidate.isSuccessful && isInBestCandidates) {
KtSuccessCallInfo(call)
@@ -34,12 +34,6 @@ public class FirResolveCandidatesTestGenerated extends AbstractResolveCandidates
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/callResolver/resolveCandidates"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("noCandidates.kt")
public void testNoCandidates() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/noCandidates.kt");
}
@Nested
@TestMetadata("analysis/analysis-api/testData/components/callResolver/resolveCandidates/multipleCandidates")
@TestDataPath("$PROJECT_ROOT")
@@ -86,6 +80,64 @@ public class FirResolveCandidatesTestGenerated extends AbstractResolveCandidates
}
}
@Nested
@TestMetadata("analysis/analysis-api/testData/components/callResolver/resolveCandidates/noCandidates")
@TestDataPath("$PROJECT_ROOT")
public class NoCandidates {
@Test
public void testAllFilesPresentInNoCandidates() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/callResolver/resolveCandidates/noCandidates"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("hiddenDeprecated.kt")
public void testHiddenDeprecated() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/noCandidates/hiddenDeprecated.kt");
}
@Test
@TestMetadata("unresolvableOperator_elvis_1.kt")
public void testUnresolvableOperator_elvis_1() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/noCandidates/unresolvableOperator_elvis_1.kt");
}
@Test
@TestMetadata("unresolvableOperator_elvis_2.kt")
public void testUnresolvableOperator_elvis_2() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/noCandidates/unresolvableOperator_elvis_2.kt");
}
@Test
@TestMetadata("unresolvableOperator_eqeqeq_1.kt")
public void testUnresolvableOperator_eqeqeq_1() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/noCandidates/unresolvableOperator_eqeqeq_1.kt");
}
@Test
@TestMetadata("unresolvableOperator_eqeqeq_2.kt")
public void testUnresolvableOperator_eqeqeq_2() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/noCandidates/unresolvableOperator_eqeqeq_2.kt");
}
@Test
@TestMetadata("unresolvableOperator_excleqeq_1.kt")
public void testUnresolvableOperator_excleqeq_1() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/noCandidates/unresolvableOperator_excleqeq_1.kt");
}
@Test
@TestMetadata("unresolvableOperator_excleqeq_2.kt")
public void testUnresolvableOperator_excleqeq_2() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/noCandidates/unresolvableOperator_excleqeq_2.kt");
}
@Test
@TestMetadata("unresolvedReference.kt")
public void testUnresolvedReference() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/noCandidates/unresolvedReference.kt");
}
}
@Nested
@TestMetadata("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate")
@TestDataPath("$PROJECT_ROOT")
@@ -95,6 +147,36 @@ public class FirResolveCandidatesTestGenerated extends AbstractResolveCandidates
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@Test
@TestMetadata("arrayOfInAnnotation.kt")
public void testArrayOfInAnnotation() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/arrayOfInAnnotation.kt");
}
@Test
@TestMetadata("builderInference.kt")
public void testBuilderInference() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/builderInference.kt");
}
@Test
@TestMetadata("checkNotNullCall.kt")
public void testCheckNotNullCall() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/checkNotNullCall.kt");
}
@Test
@TestMetadata("checkNotNullCallAsCallee.kt")
public void testCheckNotNullCallAsCallee() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/checkNotNullCallAsCallee.kt");
}
@Test
@TestMetadata("comparisonCall.kt")
public void testComparisonCall() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/comparisonCall.kt");
}
@Test
@TestMetadata("consecutiveImplicitInvoke1.kt")
public void testConsecutiveImplicitInvoke1() throws Exception {
@@ -114,15 +196,117 @@ public class FirResolveCandidatesTestGenerated extends AbstractResolveCandidates
}
@Test
@TestMetadata("functionCall.kt")
public void testFunctionCall() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionCall.kt");
@TestMetadata("eqEqCall_fromAny.kt")
public void testEqEqCall_fromAny() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/eqEqCall_fromAny.kt");
}
@Test
@TestMetadata("functionCallWithNotEnoughArgs.kt")
public void testFunctionCallWithNotEnoughArgs() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionCallWithNotEnoughArgs.kt");
@TestMetadata("eqEqCall_fromSuperType.kt")
public void testEqEqCall_fromSuperType() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/eqEqCall_fromSuperType.kt");
}
@Test
@TestMetadata("eqEqCall_overridden.kt")
public void testEqEqCall_overridden() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/eqEqCall_overridden.kt");
}
@Test
@TestMetadata("functionCallInTheSameFile.kt")
public void testFunctionCallInTheSameFile() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionCallInTheSameFile.kt");
}
@Test
@TestMetadata("functionCallWithExtensionReceiverAndTypeArgument.kt")
public void testFunctionCallWithExtensionReceiverAndTypeArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionCallWithExtensionReceiverAndTypeArgument.kt");
}
@Test
@TestMetadata("functionCallWithLambdaArgument.kt")
public void testFunctionCallWithLambdaArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionCallWithLambdaArgument.kt");
}
@Test
@TestMetadata("functionCallWithNamedArgument.kt")
public void testFunctionCallWithNamedArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionCallWithNamedArgument.kt");
}
@Test
@TestMetadata("functionCallWithNonTrailingLambdaArgument.kt")
public void testFunctionCallWithNonTrailingLambdaArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionCallWithNonTrailingLambdaArgument.kt");
}
@Test
@TestMetadata("functionCallWithSpreadArgument.kt")
public void testFunctionCallWithSpreadArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionCallWithSpreadArgument.kt");
}
@Test
@TestMetadata("functionCallWithTypeArgument.kt")
public void testFunctionCallWithTypeArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionCallWithTypeArgument.kt");
}
@Test
@TestMetadata("functionCallWithVarargArgument.kt")
public void testFunctionCallWithVarargArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionCallWithVarargArgument.kt");
}
@Test
@TestMetadata("functionTypeVariableCall_dispatchReceiver.kt")
public void testFunctionTypeVariableCall_dispatchReceiver() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionTypeVariableCall_dispatchReceiver.kt");
}
@Test
@TestMetadata("functionTypeVariableCall_extensionReceiver.kt")
public void testFunctionTypeVariableCall_extensionReceiver() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionTypeVariableCall_extensionReceiver.kt");
}
@Test
@TestMetadata("functionWithReceiverCall.kt")
public void testFunctionWithReceiverCall() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionWithReceiverCall.kt");
}
@Test
@TestMetadata("functionWithReceiverSafeCall.kt")
public void testFunctionWithReceiverSafeCall() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/functionWithReceiverSafeCall.kt");
}
@Test
@TestMetadata("hiddenConstructor.kt")
public void testHiddenConstructor() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/hiddenConstructor.kt");
}
@Test
@TestMetadata("implicitConstructorDelegationCall.kt")
public void testImplicitConstructorDelegationCall() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/implicitConstructorDelegationCall.kt");
}
@Test
@TestMetadata("implicitConstuctorCall.kt")
public void testImplicitConstuctorCall() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/implicitConstuctorCall.kt");
}
@Test
@TestMetadata("implicitJavaConstuctorCall.kt")
public void testImplicitJavaConstuctorCall() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/implicitJavaConstuctorCall.kt");
}
@Test
@@ -137,6 +321,12 @@ public class FirResolveCandidatesTestGenerated extends AbstractResolveCandidates
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/indexedGetWithNotEnoughArgs.kt");
}
@Test
@TestMetadata("indexedGetWithTooManyArgs.kt")
public void testIndexedGetWithTooManyArgs() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/indexedGetWithTooManyArgs.kt");
}
@Test
@TestMetadata("indexedSet.kt")
public void testIndexedSet() throws Exception {
@@ -149,12 +339,60 @@ public class FirResolveCandidatesTestGenerated extends AbstractResolveCandidates
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/indexedSetWithNotEnoughArgs.kt");
}
@Test
@TestMetadata("indexedSetWithTooManyArgs.kt")
public void testIndexedSetWithTooManyArgs() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/indexedSetWithTooManyArgs.kt");
}
@Test
@TestMetadata("intArrayOfInAnnotation.kt")
public void testIntArrayOfInAnnotation() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/intArrayOfInAnnotation.kt");
}
@Test
@TestMetadata("javaFunctionCall.kt")
public void testJavaFunctionCall() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/javaFunctionCall.kt");
}
@Test
@TestMetadata("memberFunctionCallWithTypeArgument.kt")
public void testMemberFunctionCallWithTypeArgument() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/memberFunctionCallWithTypeArgument.kt");
}
@Test
@TestMetadata("privateMember.kt")
public void testPrivateMember() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/privateMember.kt");
}
@Test
@TestMetadata("resolveCallInSuperConstructorParam.kt")
public void testResolveCallInSuperConstructorParam() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/resolveCallInSuperConstructorParam.kt");
}
@Test
@TestMetadata("samConstructorCall.kt")
public void testSamConstructorCall() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/samConstructorCall.kt");
}
@Test
@TestMetadata("simpleCallWithNonMatchingArgs.kt")
public void testSimpleCallWithNonMatchingArgs() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/simpleCallWithNonMatchingArgs.kt");
}
@Test
@TestMetadata("smartCastExplicitExtensionReceiver.kt")
public void testSmartCastExplicitExtensionReceiver() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/smartCastExplicitExtensionReceiver.kt");
}
@Test
@TestMetadata("variableAsFunction.kt")
public void testVariableAsFunction() throws Exception {
@@ -166,5 +404,65 @@ public class FirResolveCandidatesTestGenerated extends AbstractResolveCandidates
public void testVariableAsFunctionLikeCall() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/variableAsFunctionLikeCall.kt");
}
@Test
@TestMetadata("variableAsFunctionWithParameterName.kt")
public void testVariableAsFunctionWithParameterName() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/variableAsFunctionWithParameterName.kt");
}
@Test
@TestMetadata("variableAsFunctionWithParameterNameAnnotation.kt")
public void testVariableAsFunctionWithParameterNameAnnotation() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/variableAsFunctionWithParameterNameAnnotation.kt");
}
@Test
@TestMetadata("variableAsFunctionWithParameterNameAnnotationConflict.kt")
public void testVariableAsFunctionWithParameterNameAnnotationConflict() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/variableAsFunctionWithParameterNameAnnotationConflict.kt");
}
@Test
@TestMetadata("variableAsFunctionWithParameterNameGeneric.kt")
public void testVariableAsFunctionWithParameterNameGeneric() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/variableAsFunctionWithParameterNameGeneric.kt");
}
@Test
@TestMetadata("variableAsFunctionWithParameterNameInNonFunctionType.kt")
public void testVariableAsFunctionWithParameterNameInNonFunctionType() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/variableAsFunctionWithParameterNameInNonFunctionType.kt");
}
@Test
@TestMetadata("variableAsFunctionWithParameterNameMixed.kt")
public void testVariableAsFunctionWithParameterNameMixed() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/variableAsFunctionWithParameterNameMixed.kt");
}
@Test
@TestMetadata("variableWithExtensionInvoke.kt")
public void testVariableWithExtensionInvoke() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/variableWithExtensionInvoke.kt");
}
@Test
@TestMetadata("variableWithInvokeFunctionCall_dispatchReceiver.kt")
public void testVariableWithInvokeFunctionCall_dispatchReceiver() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/variableWithInvokeFunctionCall_dispatchReceiver.kt");
}
@Test
@TestMetadata("variableWithInvokeFunctionCall_extensionReceiver.kt")
public void testVariableWithInvokeFunctionCall_extensionReceiver() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/variableWithInvokeFunctionCall_extensionReceiver.kt");
}
@Test
@TestMetadata("variableWithMemberInvoke.kt")
public void testVariableWithMemberInvoke() throws Exception {
runTest("analysis/analysis-api/testData/components/callResolver/resolveCandidates/singleCandidate/variableWithMemberInvoke.kt");
}
}
}
@@ -0,0 +1,6 @@
@Deprecated("", level=DeprecationLevel.HIDDEN)
fun a() {}
fun test() {
<expr>a()</expr>
}
@@ -0,0 +1,5 @@
class A
fun test(a: A, b: A) {
<expr>a ?: b</expr>
}
@@ -0,0 +1,5 @@
class A
fun test(a: A, b: A) {
a <expr>?:</expr> b
}
@@ -0,0 +1,5 @@
class A
fun test(a: A, b: A) {
<expr>a === b</expr>
}
@@ -0,0 +1,5 @@
class A
fun test(a: A, b: A) {
a <expr>===</expr> b
}
@@ -0,0 +1,5 @@
class A
fun test(a: A, b: A) {
<expr>a !== b</expr>
}
@@ -0,0 +1,5 @@
class A
fun test(a: A, b: A) {
a <expr>!==</expr> b
}
@@ -0,0 +1,4 @@
annotation class RequiresPermission(val anyOf: IntArray)
@RequiresPermission(anyOf = <expr>arrayOf(1, 2, 3)</expr>)
fun foo(): Int = 5
@@ -0,0 +1,34 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Array<kotlin.Int>
symbol = kotlin/arrayOf(vararg elements: T): kotlin.Array<T>
valueParameters = [
KtVariableLikeSignature:
name = elements
receiverType = null
returnType = kotlin.Int
symbol = vararg elements: T
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = elements
receiverType = null
returnType = kotlin.Int
symbol = vararg elements: T),
2 -> (KtVariableLikeSignature:
name = elements
receiverType = null
returnType = kotlin.Int
symbol = vararg elements: T),
3 -> (KtVariableLikeSignature:
name = elements
receiverType = null
returnType = kotlin.Int
symbol = vararg elements: T)
}
@@ -0,0 +1,14 @@
// WITH_STDLIB
package test
class Target<T> {
fun add(t: T) {}
}
fun <T> buildTarget(@BuilderInference block: Target<T>.() -> Unit): Target<T> {
return Target<T>().apply { block() }
}
fun test(s: String) {
val result = buildTarget { <expr>add</expr>(s) }
}
@@ -0,0 +1,27 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtImplicitReceiverValue:
symbol = KtReceiverParameterSymbol:
origin: SOURCE
type: test/Target<kotlin/String>
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = test/Target.add(<dispatch receiver>: test.Target<T>, t: T): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = t
receiverType = null
returnType = T
symbol = t: T
]
argumentMapping = {
s -> (KtVariableLikeSignature:
name = t
receiverType = null
returnType = T
symbol = t: T)
}
@@ -0,0 +1,3 @@
fun test(a: Any?) {
<expr>a!!</expr>
}
@@ -0,0 +1,3 @@
KtSuccessCallInfo:
call = KtCheckNotNullCall:
baseExpression = a
@@ -0,0 +1,3 @@
fun test(a: (() -> Unit)?) {
<expr>a!!</expr>()
}
@@ -0,0 +1,3 @@
KtSuccessCallInfo:
call = KtCheckNotNullCall:
baseExpression = a
@@ -0,0 +1,3 @@
fun test(i: Int, j: Int) {
<expr>i < j</expr>
}
@@ -0,0 +1,26 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = i
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Int
symbol = kotlin/Int.compareTo(<dispatch receiver>: kotlin.Int, other: kotlin.Int): kotlin.Int
valueParameters = [
KtVariableLikeSignature:
name = other
receiverType = null
returnType = kotlin.Int
symbol = other: kotlin.Int
]
argumentMapping = {
j -> (KtVariableLikeSignature:
name = other
receiverType = null
returnType = kotlin.Int
symbol = other: kotlin.Int)
}
@@ -47,4 +47,4 @@ KtErrorCallInfo:
valueParameters = []
argumentMapping = {}
]
diagnostic = ERROR<UNRESOLVED_REFERENCE_WRONG_RECEIVER: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: [/invoke]>
diagnostic = ERROR<UNRESOLVED_REFERENCE_WRONG_RECEIVER: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: [/invoke]>
@@ -47,4 +47,4 @@ KtErrorCallInfo:
valueParameters = []
argumentMapping = {}
]
diagnostic = ERROR<UNRESOLVED_REFERENCE_WRONG_RECEIVER: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: [/invoke]>
diagnostic = ERROR<UNRESOLVED_REFERENCE_WRONG_RECEIVER: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: [/invoke]>
@@ -47,4 +47,4 @@ KtSuccessCallInfo:
returnType = kotlin.Unit
symbol = /invoke(<extension receiver>: kotlin.Double): kotlin.Unit
valueParameters = []
argumentMapping = {}
argumentMapping = {}
@@ -0,0 +1,5 @@
class B
fun test(b1: B, b2: B) {
<expr>b1 == b2</expr>
}
@@ -0,0 +1,26 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = b1
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Boolean
symbol = kotlin/Any.equals(<dispatch receiver>: kotlin.Any, other: kotlin.Any?): kotlin.Boolean
valueParameters = [
KtVariableLikeSignature:
name = other
receiverType = null
returnType = kotlin.Any?
symbol = other: kotlin.Any?
]
argumentMapping = {
b2 -> (KtVariableLikeSignature:
name = other
receiverType = null
returnType = kotlin.Any?
symbol = other: kotlin.Any?)
}
@@ -0,0 +1,11 @@
open class A {
override fun equals(other: Any?): Boolean {
return true
}
}
class B : A()
fun test(b1: B, b2: B) {
<expr>b1 == b2</expr>
}
@@ -0,0 +1,26 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = b1
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Boolean
symbol = /A.equals(<dispatch receiver>: A, other: kotlin.Any?): kotlin.Boolean
valueParameters = [
KtVariableLikeSignature:
name = other
receiverType = null
returnType = kotlin.Any?
symbol = other: kotlin.Any?
]
argumentMapping = {
b2 -> (KtVariableLikeSignature:
name = other
receiverType = null
returnType = kotlin.Any?
symbol = other: kotlin.Any?)
}
@@ -0,0 +1,9 @@
open class A {
override fun equals(other: Any?): Boolean {
return true
}
}
fun test(a1: A, a2: A) {
<expr>a1 == a2</expr>
}
@@ -0,0 +1,26 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = a1
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Boolean
symbol = /A.equals(<dispatch receiver>: A, other: kotlin.Any?): kotlin.Boolean
valueParameters = [
KtVariableLikeSignature:
name = other
receiverType = null
returnType = kotlin.Any?
symbol = other: kotlin.Any?
]
argumentMapping = {
a2 -> (KtVariableLikeSignature:
name = other
receiverType = null
returnType = kotlin.Any?
symbol = other: kotlin.Any?)
}
@@ -0,0 +1,5 @@
fun <A, B> A.function(a: B) {}
fun call() {
"str".<expr>function(1)</expr>
}
@@ -0,0 +1,26 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = KtExplicitReceiverValue:
expression = "str"
isSafeNavigation = false
signature = KtFunctionLikeSignature:
receiverType = kotlin.String
returnType = kotlin.Unit
symbol = /function(<extension receiver>: A, a: B): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: B
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: B)
}
@@ -0,0 +1,5 @@
fun function(a: Int, b: (String) -> Boolean) {}
fun call() {
<expr>function(1) { s -> true }</expr>
}
@@ -0,0 +1,34 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(a: kotlin.Int, b: kotlin.Function1<kotlin.String, kotlin.Boolean>): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: kotlin.Int,
KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.Function1<kotlin.String, kotlin.Boolean>
symbol = b: kotlin.Function1<kotlin.String, kotlin.Boolean>
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: kotlin.Int),
{ s -> true } -> (KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.Function1<kotlin.String, kotlin.Boolean>
symbol = b: kotlin.Function1<kotlin.String, kotlin.Boolean>)
}
@@ -1,5 +1,5 @@
fun function(a: Int, b: String) {}
fun call() {
<expr>function(1)</expr>
<expr>function(b = "foo", a = 1)</expr>
}
@@ -0,0 +1,34 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(a: kotlin.Int, b: kotlin.String): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: kotlin.Int,
KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.String
symbol = b: kotlin.String
]
argumentMapping = {
"foo" -> (KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.String
symbol = b: kotlin.String),
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: kotlin.Int)
}
@@ -0,0 +1,5 @@
fun function(a: Int, b: (String) -> Boolean) {}
fun call() {
<expr>function(1, { s -> true })</expr>
}
@@ -0,0 +1,34 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(a: kotlin.Int, b: kotlin.Function1<kotlin.String, kotlin.Boolean>): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: kotlin.Int,
KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.Function1<kotlin.String, kotlin.Boolean>
symbol = b: kotlin.Function1<kotlin.String, kotlin.Boolean>
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: kotlin.Int),
{ s -> true } -> (KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.Function1<kotlin.String, kotlin.Boolean>
symbol = b: kotlin.Function1<kotlin.String, kotlin.Boolean>)
}
@@ -0,0 +1,6 @@
fun function(vararg a: Int) {}
fun call() {
val args = intArrayOf(1, 2, 3)
<expr>function(*args)</expr>
}
@@ -0,0 +1,24 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(vararg a: kotlin.Int): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = vararg a: kotlin.Int
]
argumentMapping = {
args -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = vararg a: kotlin.Int)
}
@@ -0,0 +1,5 @@
fun <A, B> function(a: A, b: B) {}
fun call() {
<expr>function(1, "")</expr>
}
@@ -0,0 +1,34 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(a: A, b: B): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: A,
KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.String
symbol = b: B
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: A),
"" -> (KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.String
symbol = b: B)
}
@@ -0,0 +1,5 @@
fun function(vararg a: Int) {}
fun call() {
<expr>function(1, 2, 3)</expr>
}
@@ -0,0 +1,34 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(vararg a: kotlin.Int): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = vararg a: kotlin.Int
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = vararg a: kotlin.Int),
2 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = vararg a: kotlin.Int),
3 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = vararg a: kotlin.Int)
}
@@ -0,0 +1,6 @@
class A {
val f: String.() -> Unit = {}
fun test() {
"".<expr>f()</expr>
}
}
@@ -0,0 +1,22 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = true
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = f
isSafeNavigation = false
extensionReceiver = KtExplicitReceiverValue:
expression = ""
isSafeNavigation = false
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = kotlin/Function1.invoke(<dispatch receiver>: kotlin.Function1<P1, R>, p1: P1): R
valueParameters = [
KtVariableLikeSignature:
name = p1
receiverType = null
returnType = kotlin.String
symbol = p1: P1
]
argumentMapping = {}
@@ -0,0 +1,7 @@
class A {
fun test() {
"".<expr>f()</expr>
}
}
val A.f: String.() -> Unit = {}
@@ -0,0 +1,22 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = true
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = f
isSafeNavigation = false
extensionReceiver = KtExplicitReceiverValue:
expression = ""
isSafeNavigation = false
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = kotlin/Function1.invoke(<dispatch receiver>: kotlin.Function1<P1, R>, p1: P1): R
valueParameters = [
KtVariableLikeSignature:
name = p1
receiverType = null
returnType = kotlin.String
symbol = p1: P1
]
argumentMapping = {}
@@ -0,0 +1,5 @@
fun String.function(a: Int) {}
fun call() {
"str".<expr>function(1)</expr>
}
@@ -0,0 +1,26 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = KtExplicitReceiverValue:
expression = "str"
isSafeNavigation = false
signature = KtFunctionLikeSignature:
receiverType = kotlin.String
returnType = kotlin.Unit
symbol = /function(<extension receiver>: kotlin.String, a: kotlin.Int): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: kotlin.Int
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: kotlin.Int)
}
@@ -0,0 +1,5 @@
fun String.function(a: Int) {}
fun call() {
"str"?.<expr>function(1)</expr>
}
@@ -0,0 +1,26 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = KtExplicitReceiverValue:
expression = "str"
isSafeNavigation = true
signature = KtFunctionLikeSignature:
receiverType = kotlin.String
returnType = kotlin.Unit
symbol = /function(<extension receiver>: kotlin.String, a: kotlin.Int): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: kotlin.Int
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: kotlin.Int)
}
@@ -0,0 +1,5 @@
fun test() {
<expr>Obj(555)</expr>
}
object Obj
@@ -0,0 +1,15 @@
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = Obj
symbol = <constructor>(): Obj
valueParameters = []
argumentMapping = {}
]
diagnostic = ERROR<INVISIBLE_REFERENCE: Symbol /Obj.Obj is invisible>
@@ -0,0 +1,7 @@
class A {
constructor(i: Int)
}
fun call() {
val a = <expr>A(42)</expr>
}
@@ -0,0 +1,24 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = A
symbol = <constructor>(i: kotlin.Int): A
valueParameters = [
KtVariableLikeSignature:
name = i
receiverType = null
returnType = kotlin.Int
symbol = i: kotlin.Int
]
argumentMapping = {
42 -> (KtVariableLikeSignature:
name = i
receiverType = null
returnType = kotlin.Int
symbol = i: kotlin.Int)
}
@@ -0,0 +1,5 @@
class A
fun call() {
val a = <expr>A()</expr>
}
@@ -0,0 +1,12 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = A
symbol = <constructor>(): A
valueParameters = []
argumentMapping = {}
@@ -0,0 +1,7 @@
// FILE: call.kt
fun call() {
val a = <expr>A()</expr>
}
// FILE: A.java
class A {}
@@ -0,0 +1,12 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = A
symbol = <constructor>(): A
valueParameters = []
argumentMapping = {}
@@ -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,12 +3,14 @@ KtErrorCallInfo:
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
dispatchReceiver = KtExplicitReceiverValue:
expression = c
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /function(a: kotlin.Int, b: kotlin.String): kotlin.Unit
returnType = kotlin.Boolean
symbol = /C.get(<dispatch receiver>: C, a: kotlin.Int, b: kotlin.String): kotlin.Boolean
valueParameters = [
KtVariableLikeSignature:
name = a
@@ -26,7 +28,12 @@ KtErrorCallInfo:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: kotlin.Int)
symbol = a: kotlin.Int),
"foo" -> (KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.String
symbol = b: kotlin.String)
}
]
diagnostic = ERROR<NO_VALUE_FOR_PARAMETER: No value passed for parameter 'b'>
diagnostic = ERROR<TOO_MANY_ARGUMENTS: Too many arguments for public final operator fun /C.get(a: R|kotlin/Int|, b: R|kotlin/String|): R|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", 3.14]</expr> = false
}
@@ -0,0 +1,49 @@
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = c
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /C.set(<dispatch receiver>: C, a: kotlin.Int, b: kotlin.String, value: kotlin.Boolean): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: kotlin.Int,
KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.String
symbol = b: kotlin.String,
KtVariableLikeSignature:
name = value
receiverType = null
returnType = kotlin.Boolean
symbol = value: kotlin.Boolean
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = kotlin.Int
symbol = a: kotlin.Int),
"foo" -> (KtVariableLikeSignature:
name = b
receiverType = null
returnType = kotlin.String
symbol = b: kotlin.String),
false -> (KtVariableLikeSignature:
name = value
receiverType = null
returnType = kotlin.Boolean
symbol = value: kotlin.Boolean)
}
]
diagnostic = ERROR<TOO_MANY_ARGUMENTS: 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|>
@@ -0,0 +1,4 @@
annotation class RequiresPermission(val anyOf: IntArray)
@RequiresPermission(anyOf = <expr>intArrayOf(1, 2, 3)</expr>)
fun foo(): Int = 5
@@ -0,0 +1,34 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.IntArray
symbol = kotlin/intArrayOf(vararg elements: kotlin.Int): kotlin.IntArray
valueParameters = [
KtVariableLikeSignature:
name = elements
receiverType = null
returnType = kotlin.Int
symbol = vararg elements: kotlin.Int
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = elements
receiverType = null
returnType = kotlin.Int
symbol = vararg elements: kotlin.Int),
2 -> (KtVariableLikeSignature:
name = elements
receiverType = null
returnType = kotlin.Int
symbol = vararg elements: kotlin.Int),
3 -> (KtVariableLikeSignature:
name = elements
receiverType = null
returnType = kotlin.Int
symbol = vararg elements: kotlin.Int)
}
@@ -0,0 +1,10 @@
// FILE: call.kt
fun call() {
val javaClass = JavaClass()
javaClass.<expr>javaMethod()</expr>
}
// FILE: JavaClass.java
class JavaClass {
void javaMethod() {}
}
@@ -0,0 +1,14 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = javaClass
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /JavaClass.javaMethod(<dispatch receiver>: JavaClass): kotlin.Unit
valueParameters = []
argumentMapping = {}
@@ -0,0 +1,7 @@
interface A<T> {
fun <R> foo(r: R)
}
fun call(a: A<String>) {
a.<expr>foo(1)</expr>
}
@@ -0,0 +1,26 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = a
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /A.foo(<dispatch receiver>: A<T>, r: R): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = r
receiverType = null
returnType = kotlin.Int
symbol = r: R
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = r
receiverType = null
returnType = kotlin.Int
symbol = r: R)
}
@@ -0,0 +1,7 @@
class A {
private fun foo() {}
}
fun test(a: A) {
<expr>a.foo()</expr>
}
@@ -0,0 +1,17 @@
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = a
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /A.foo(<dispatch receiver>: A): kotlin.Unit
valueParameters = []
argumentMapping = {}
]
diagnostic = ERROR<INVISIBLE_REFERENCE: Symbol /A.foo is invisible>
@@ -0,0 +1,5 @@
infix fun <A, B> A.to(other: B) = this
open class A<T>(x: T)
class B : A(<expr>1 to 2</expr>)
@@ -0,0 +1,26 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = KtExplicitReceiverValue:
expression = 1
isSafeNavigation = false
signature = KtFunctionLikeSignature:
receiverType = kotlin.Int
returnType = kotlin.Int
symbol = /to(<extension receiver>: A, other: B): A
valueParameters = [
KtVariableLikeSignature:
name = other
receiverType = null
returnType = kotlin.Int
symbol = other: B
]
argumentMapping = {
2 -> (KtVariableLikeSignature:
name = other
receiverType = null
returnType = kotlin.Int
symbol = other: B)
}
@@ -0,0 +1,5 @@
fun x() {
<expr>foo(1)</expr>
}
fun foo(){}
@@ -0,0 +1,15 @@
KtErrorCallInfo:
candidateCalls = [
KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /foo(): kotlin.Unit
valueParameters = []
argumentMapping = {}
]
diagnostic = ERROR<TOO_MANY_ARGUMENTS: Too many arguments for public final fun /foo(): R|kotlin/Unit|>
@@ -0,0 +1,7 @@
fun test(a: Any) {
if (a is String) {
a.<expr>foo()</expr>
}
}
fun String.foo() {}
@@ -0,0 +1,16 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = KtSmartCastedReceiverValue:
original = KtExplicitReceiverValue:
expression = a
isSafeNavigation = false
smartCastType = kotlin.String
signature = KtFunctionLikeSignature:
receiverType = kotlin.String
returnType = kotlin.Unit
symbol = /foo(<extension receiver>: kotlin.String): kotlin.Unit
valueParameters = []
argumentMapping = {}
@@ -0,0 +1,3 @@
fun call(x: (a: Int, b: String) -> Unit) {
<expr>x(1, "")</expr>
}
@@ -0,0 +1,36 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = true
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = x
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = kotlin/Function2.invoke(<dispatch receiver>: kotlin.Function2<P1, P2, R>, p1: P1, p2: P2): R
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(a)) kotlin.Int
symbol = p1: P1,
KtVariableLikeSignature:
name = b
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(b)) kotlin.String
symbol = p2: P2
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(a)) kotlin.Int
symbol = p1: P1),
"" -> (KtVariableLikeSignature:
name = b
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(b)) kotlin.String
symbol = p2: P2)
}
@@ -0,0 +1,3 @@
fun call(x: Function2<@ParameterName("a") Int, @ParameterName("b") String, Unit>) {
<expr>x(1, "")</expr>
}
@@ -0,0 +1,36 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = true
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = x
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = kotlin/Function2.invoke(<dispatch receiver>: kotlin.Function2<P1, P2, R>, p1: P1, p2: P2): R
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(a)) kotlin.Int
symbol = p1: P1,
KtVariableLikeSignature:
name = b
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(b)) kotlin.String
symbol = p2: P2
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(a)) kotlin.Int
symbol = p1: P1),
"" -> (KtVariableLikeSignature:
name = b
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(b)) kotlin.String
symbol = p2: P2)
}
@@ -0,0 +1,4 @@
// @ParameterName annotation takes precedence over name in function type parameter
fun call(x: (notMe: @ParameterName("a") Int, meNeither: @ParameterName("b") String) -> Unit) {
<expr>x(1, "")</expr>
}
@@ -0,0 +1,36 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = true
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = x
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = kotlin/Function2.invoke(<dispatch receiver>: kotlin.Function2<P1, P2, R>, p1: P1, p2: P2): R
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(a)) kotlin.Int
symbol = p1: P1,
KtVariableLikeSignature:
name = b
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(b)) kotlin.String
symbol = p2: P2
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(a)) kotlin.Int
symbol = p1: P1),
"" -> (KtVariableLikeSignature:
name = b
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(b)) kotlin.String
symbol = p2: P2)
}
@@ -0,0 +1,6 @@
fun <T> T.foo(): (a: T) -> Unit = TODO()
fun call() {
val x = 123.foo()
<expr>x(1)</expr>
}
@@ -0,0 +1,26 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = true
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = x
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = kotlin/Function1.invoke(<dispatch receiver>: kotlin.Function1<P1, R>, p1: P1): R
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(a)) kotlin.Int
symbol = p1: P1
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(a)) kotlin.Int
symbol = p1: P1)
}
@@ -0,0 +1,4 @@
// @ParameterName annotation is ignored when not used in function type
fun call(a: @ParameterName("notMe") Int, b: @ParameterName("meNeither") String) {
<expr>call(1, "")</expr>
}
@@ -0,0 +1,34 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = false
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = null
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = /call(a: @R|kotlin.ParameterName|(name = String(notMe)) kotlin.Int, b: @R|kotlin.ParameterName|(name = String(meNeither)) kotlin.String): kotlin.Unit
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(notMe)) kotlin.Int
symbol = a: @R|kotlin.ParameterName|(name = String(notMe)) kotlin.Int,
KtVariableLikeSignature:
name = b
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(meNeither)) kotlin.String
symbol = b: @R|kotlin.ParameterName|(name = String(meNeither)) kotlin.String
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(notMe)) kotlin.Int
symbol = a: @R|kotlin.ParameterName|(name = String(notMe)) kotlin.Int),
"" -> (KtVariableLikeSignature:
name = b
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(meNeither)) kotlin.String
symbol = b: @R|kotlin.ParameterName|(name = String(meNeither)) kotlin.String)
}
@@ -0,0 +1,3 @@
fun call(x: (a: Int, String) -> Unit) {
<expr>x(1, "")</expr>
}
@@ -0,0 +1,36 @@
KtSuccessCallInfo:
call = KtSimpleFunctionCall:
isImplicitInvoke = true
partiallyAppliedSymbol = KtPartiallyAppliedSymbol:
dispatchReceiver = KtExplicitReceiverValue:
expression = x
isSafeNavigation = false
extensionReceiver = null
signature = KtFunctionLikeSignature:
receiverType = null
returnType = kotlin.Unit
symbol = kotlin/Function2.invoke(<dispatch receiver>: kotlin.Function2<P1, P2, R>, p1: P1, p2: P2): R
valueParameters = [
KtVariableLikeSignature:
name = a
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(a)) kotlin.Int
symbol = p1: P1,
KtVariableLikeSignature:
name = p2
receiverType = null
returnType = kotlin.String
symbol = p2: P2
]
argumentMapping = {
1 -> (KtVariableLikeSignature:
name = a
receiverType = null
returnType = @R|kotlin.ParameterName|(name = String(a)) kotlin.Int
symbol = p1: P1),
"" -> (KtVariableLikeSignature:
name = p2
receiverType = null
returnType = kotlin.String
symbol = p2: P2)
}
@@ -0,0 +1,7 @@
interface Foo
operator fun <T> Foo.invoke(t: T) {}
fun test(f: Foo) {
<expr>f("")</expr>
}

Some files were not shown because too many files have changed in this diff Show More