[kotlin] support default parameter values in SameParameterValue inspection

- if we provide the default parameter value in `FirKotlinUastResolveProviderService.getArgumentForParameter`, then the omitted argument would be counted as real value (was not the case for k1)

^KTIJ-34329 fixed

GitOrigin-RevId: 161d994ff994175fa51a445e76dac091fae8b886
This commit is contained in:
Anna Kozlova
2025-06-18 21:36:51 +00:00
committed by intellij-monorepo-bot
parent 6033562059
commit 1e8aad50b0
4 changed files with 24 additions and 2 deletions
@@ -525,7 +525,6 @@ public sealed class RefMethodImpl extends RefJavaElementImpl implements RefMetho
void updateParameterValues(@NotNull UCallExpression call, @Nullable PsiElement elementPlace) {
LOG.assertTrue(isInitialized());
if (call.getValueArguments().isEmpty()) return;
if (isExternalOverride()) return;
if (!getSuperMethods().isEmpty()) {
@@ -110,7 +110,7 @@ public final class RefParameterImpl extends RefJavaElementImpl implements RefPar
myActualValueTemplate = VALUE_IS_NOT_CONST;
}
synchronized void updateTemplateValue(UExpression expression, @Nullable PsiElement accessPlace) {
synchronized void updateTemplateValue(@Nullable UExpression expression, @Nullable PsiElement accessPlace) {
myUsageCount++;
if (myActualValueTemplate == VALUE_IS_NOT_CONST) return;
@@ -6,3 +6,22 @@ private fun String.privateFunctionWithReceiverAndVarargs(vararg fields: Int) {}
suspend fun String.publicSuspendFunction() = privateSuspendFunctionWithReceiverAndVarargs(1, 2, 3)
suspend fun String.publicSuspendFunction2() = privateSuspendFunctionWithReceiverAndVarargs(1, 2, 3)
private suspend fun String.privateSuspendFunctionWithReceiverAndVarargs(vararg fields: Int) {}
interface Fixture {}
private suspend fun Fixture.resolveRuntimeClasspath(projectPath: String = "") {}
public suspend fun main(f: Fixture) {
f.resolveRuntimeClasspath("F")
f.resolveRuntimeClasspath("F")
f.resolveRuntimeClasspath("F")
f.resolveRuntimeClasspath()
}
private suspend fun Fixture.sameAsDefault(projectPath: String = "F") {}
public suspend fun main(f: Fixture) {
f.sameAsDefault("F")
f.sameAsDefault("F")
f.sameAsDefault("F")
f.sameAsDefault()
}
@@ -28,4 +28,8 @@ abstract class KotlinSameParameterValueGlobalInspectionTest : SameParameterValue
fun testNegativeDouble() {
doHighlightTest()
}
fun testReceiver() {
doHighlightTest()
}
}