Call arguments should not affect parameter names returned in MethodInfo
The parameter names are only used for blacklist filtering, and should correspond only to the function being called; the order and number of actually provided arguments does not matter.
This commit is contained in:
+2
-7
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getStrictParentOfType
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
@@ -173,16 +172,12 @@ class KotlinInlayParameterHintsProvider : InlayParameterHintsProvider {
|
||||
val resolvedCall = elem.getResolvedCall(ctx)
|
||||
val resolvedCallee = resolvedCall?.candidateDescriptor
|
||||
if (resolvedCallee is FunctionDescriptor) {
|
||||
val paramNames =
|
||||
resolvedCallee.valueParameters.map { it.name }.filter { !it.isSpecial }.map(Name::asString)
|
||||
val fqName = if (resolvedCallee is ConstructorDescriptor)
|
||||
resolvedCallee.containingDeclaration.fqNameSafe.asString()
|
||||
else
|
||||
(resolvedCallee.fqNameOrNull()?.asString() ?: return null)
|
||||
val paramNames = resolvedCall.valueArguments
|
||||
.mapNotNull { (valueParameterDescriptor, resolvedValueArgument) ->
|
||||
if (resolvedValueArgument !is DefaultValueArgument) valueParameterDescriptor.name else null
|
||||
}
|
||||
.filter { !it.isSpecial }
|
||||
.map(Name::asString)
|
||||
return HintInfo.MethodInfo(fqName, paramNames)
|
||||
}
|
||||
return null
|
||||
|
||||
@@ -184,4 +184,8 @@ annotation class ManyArgs(val name: String, val surname: String)
|
||||
}"""
|
||||
)
|
||||
}
|
||||
|
||||
fun `test incomplete Pair call`() {
|
||||
check("val x = Pair(1, )")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user