Correctly show parameter name hints for non-ambiguous overloads
This commit is contained in:
@@ -26,12 +26,17 @@ import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
|
||||
fun provideArgumentNameHints(element: KtCallExpression): List<InlayInfo> {
|
||||
val ctx = element.analyze(BodyResolveMode.PARTIAL)
|
||||
val call = element.getCall(ctx) ?: return emptyList()
|
||||
val resolvedCall = call.getResolvedCall(ctx)
|
||||
if (resolvedCall != null) {
|
||||
return getParameterInfoForCallCandidate(resolvedCall)
|
||||
}
|
||||
val candidates = call.resolveCandidates(ctx, element.getResolutionFacade())
|
||||
if (candidates.isEmpty()) return emptyList()
|
||||
candidates.singleOrNull()?.let { return getParameterInfoForCallCandidate(it) }
|
||||
|
||||
@@ -115,6 +115,17 @@ class InlayParameterHintsTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
""")
|
||||
}
|
||||
|
||||
fun `test show non-ambiguous overload`() {
|
||||
check("""
|
||||
fun main() {
|
||||
test(<hint text="a:"/>10, <hint text="bI:"/>15);
|
||||
}
|
||||
fun test() {}
|
||||
fun test(a: Int, bS: String) {}
|
||||
fun test(a: Int, bI: Int) {}
|
||||
""")
|
||||
}
|
||||
|
||||
fun `test show ambiguous constructor`() {
|
||||
check("""
|
||||
fun main() {
|
||||
|
||||
Reference in New Issue
Block a user