KT-12104: Fix smart completion for argument of implicit invoke
#KT-12104 fixed
This commit is contained in:
committed by
Simon Ogorodnik
parent
8077a71aec
commit
fa3f87492c
@@ -0,0 +1,6 @@
|
|||||||
|
fun foo(actions: List<(String) -> Unit>) {
|
||||||
|
actions[0](<caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// EXIST: {"lookupString":"String","tailText":"() (kotlin)","itemText":"String"}
|
||||||
|
// EXIST: {"lookupString":"toString","tailText":"() (kotlin)","typeText":"String","itemText":"String.toString"}
|
||||||
+6
@@ -204,6 +204,12 @@ public class JvmSmartCompletionTestGenerated extends AbstractJvmSmartCompletionT
|
|||||||
doTest(fileName);
|
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")
|
@TestMetadata("ImplicitlyTypedFunBody.kt")
|
||||||
public void testImplicitlyTypedFunBody() throws Exception {
|
public void testImplicitlyTypedFunBody() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/ImplicitlyTypedFunBody.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/idea-completion/testData/smart/ImplicitlyTypedFunBody.kt");
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.psi.*
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis
|
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelectorOrThis
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext
|
import org.jetbrains.kotlin.resolve.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getTargetFunctionDescriptor
|
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.allArgumentsMapped
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
|
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||||
@@ -231,6 +232,10 @@ class ExpectedInfos(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun calculateForArgument(call: Call, callExpectedType: KotlinType, argument: ValueArgument): Collection<ExpectedInfo> {
|
private fun calculateForArgument(call: Call, callExpectedType: KotlinType, argument: ValueArgument): Collection<ExpectedInfo> {
|
||||||
|
|
||||||
|
if (call is CallTransformer.CallForImplicitInvoke)
|
||||||
|
return calculateForArgument(call.outerCall, callExpectedType, argument)
|
||||||
|
|
||||||
val argumentIndex = call.valueArguments.indexOf(argument)
|
val argumentIndex = call.valueArguments.indexOf(argument)
|
||||||
assert(argumentIndex >= 0) {
|
assert(argumentIndex >= 0) {
|
||||||
"Could not find argument '$argument(${argument.asElement().text})' among arguments of call: $call. Call element text: '${call.callElement.text}'"
|
"Could not find argument '$argument(${argument.asElement().text})' among arguments of call: $call. Call element text: '${call.callElement.text}'"
|
||||||
|
|||||||
Reference in New Issue
Block a user