diff --git a/idea/idea-completion/testData/smart/ImplicitInvoke.kt b/idea/idea-completion/testData/smart/ImplicitInvoke.kt new file mode 100644 index 00000000000..efb3e5b0495 --- /dev/null +++ b/idea/idea-completion/testData/smart/ImplicitInvoke.kt @@ -0,0 +1,6 @@ +fun foo(actions: List<(String) -> Unit>) { + actions[0]() +} + +// EXIST: {"lookupString":"String","tailText":"() (kotlin)","itemText":"String"} +// EXIST: {"lookupString":"toString","tailText":"() (kotlin)","typeText":"String","itemText":"String.toString"} \ No newline at end of file diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java index 2c2cc71ab7f..a2e26e389e4 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/JvmSmartCompletionTestGenerated.java @@ -204,6 +204,12 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT doTest(fileName); } + @TestMetadata("ImplicitInvoke.kt") + public void testImplicitInvoke() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/ImplicitInvoke.kt"); + doTest(fileName); + } + @TestMetadata("ImplicitlyTypedFunBody.kt") public void testImplicitlyTypedFunBody() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/ImplicitlyTypedFunBody.kt"); diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ExpectedInfos.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ExpectedInfos.kt index adc72432972..0dbe01bf5bd 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ExpectedInfos.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/ExpectedInfos.kt @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.bindingContextUtil.getTargetFunctionDescriptor +import org.jetbrains.kotlin.resolve.calls.CallTransformer import org.jetbrains.kotlin.resolve.calls.callUtil.allArgumentsMapped import org.jetbrains.kotlin.resolve.calls.callUtil.getCall import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall @@ -231,6 +232,10 @@ class ExpectedInfos( } private fun calculateForArgument(call: Call, callExpectedType: KotlinType, argument: ValueArgument): Collection { + + if (call is CallTransformer.CallForImplicitInvoke) + return calculateForArgument(call.outerCall, callExpectedType, argument) + val argumentIndex = call.valueArguments.indexOf(argument) assert(argumentIndex >= 0) { "Could not find argument '$argument(${argument.asElement().text})' among arguments of call: $call. Call element text: '${call.callElement.text}'"