Fixed bug with local function
This commit is contained in:
+12
-8
@@ -259,13 +259,9 @@ class KotlinFunctionParameterInfoHandler : ParameterInfoHandlerWithTabActionSupp
|
|||||||
functionDescriptor: FunctionDescriptor,
|
functionDescriptor: FunctionDescriptor,
|
||||||
bindingContext: BindingContext
|
bindingContext: BindingContext
|
||||||
): Boolean {
|
): Boolean {
|
||||||
val callNameExpression = getCallNameExpression(argumentList)
|
val callNameExpression = getCallNameExpression(argumentList) ?: return false
|
||||||
if (callNameExpression != null) {
|
val target = bindingContext[BindingContext.REFERENCE_TARGET, callNameExpression] as? FunctionDescriptor
|
||||||
val declarationDescriptor = bindingContext[BindingContext.REFERENCE_TARGET, callNameExpression]
|
return target != null && descriptorsEqual(target, functionDescriptor)
|
||||||
if (declarationDescriptor?.original === functionDescriptor.original) return true
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCallNameExpression(argumentList: JetValueArgumentList): JetSimpleNameExpression? {
|
private fun getCallNameExpression(argumentList: JetValueArgumentList): JetSimpleNameExpression? {
|
||||||
@@ -338,7 +334,7 @@ class KotlinFunctionParameterInfoHandler : ParameterInfoHandlerWithTabActionSupp
|
|||||||
}
|
}
|
||||||
|
|
||||||
val candidates = detectCandidates(callToUse, bindingContext, resolutionFacade)
|
val candidates = detectCandidates(callToUse, bindingContext, resolutionFacade)
|
||||||
val resolvedCall = candidates.singleOrNull { it.resultingDescriptor.original == overload.original } ?: return null
|
val resolvedCall = candidates.singleOrNull { descriptorsEqual(it.resultingDescriptor, overload) } ?: return null
|
||||||
val resultingDescriptor = resolvedCall.resultingDescriptor
|
val resultingDescriptor = resolvedCall.resultingDescriptor
|
||||||
|
|
||||||
val argumentToParameter = { argument: ValueArgument -> (resolvedCall.getArgumentMapping(argument) as? ArgumentMatch)?.valueParameter }
|
val argumentToParameter = { argument: ValueArgument -> (resolvedCall.getArgumentMapping(argument) as? ArgumentMatch)?.valueParameter }
|
||||||
@@ -385,5 +381,13 @@ class KotlinFunctionParameterInfoHandler : ParameterInfoHandlerWithTabActionSupp
|
|||||||
Visibilities.isVisible(thisReceiver, it.resultingDescriptor, inDescriptor)
|
Visibilities.isVisible(thisReceiver, it.resultingDescriptor, inDescriptor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we should not compare descriptors directly because partial resolve is involved
|
||||||
|
private fun descriptorsEqual(descriptor1: FunctionDescriptor, descriptor2: FunctionDescriptor): Boolean {
|
||||||
|
if (descriptor1.original == descriptor2.original) return true
|
||||||
|
val declaration1 = DescriptorToSourceUtils.descriptorToDeclaration(descriptor1) ?: return false
|
||||||
|
val declaration2 = DescriptorToSourceUtils.descriptorToDeclaration(descriptor2)
|
||||||
|
return declaration1 == declaration2
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
fun foo() {
|
||||||
|
fun fff(p: String, c: Char) {}
|
||||||
|
|
||||||
|
fff(<caret>)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TYPE: "1, "
|
||||||
|
|
||||||
|
//Text: (p: String, <highlight>c: Char</highlight>), Disabled: true, Strikeout: false, Green: true
|
||||||
+6
@@ -77,6 +77,12 @@ public class FunctionParameterInfoTestGenerated extends AbstractFunctionParamete
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("LocalFunctionBug.kt")
|
||||||
|
public void testLocalFunctionBug() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/LocalFunctionBug.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("NamedAndDefaultParameter.kt")
|
@TestMetadata("NamedAndDefaultParameter.kt")
|
||||||
public void testNamedAndDefaultParameter() throws Exception {
|
public void testNamedAndDefaultParameter() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/NamedAndDefaultParameter.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/parameterInfo/functionParameterInfo/NamedAndDefaultParameter.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user