Repository: detekt/detekt (kotlin)

Issue:
False positive UnnamedParameterUse when invoking a lambda
```kotlin
class OnboardingPhoneNumberNavigator(
  private val onNavigateToRequestPin: (String, String) -> Unit,
) {
  fun navigateToRequestPin(
    country: Country,
    phoneNumber: String,
  ) {
    onNavigateToRequestPin(country.code, phoneNumber)
  }
}
```

## Your Environment
* Version of detekt used: 2.0.0-alpha.0
* Version of Gradle used (if applicable): 9.0.0

Pull request description:
…aram can't be used)

Fixes https://github.com/detekt/detekt/issues/8601

Patch:
diff --git a/detekt-rules-errorprone/src/main/kotlin/dev/detekt/rules/bugs/UnnamedParameterUse.kt b/detekt-rules-errorprone/src/main/kotlin/dev/detekt/rules/bugs/UnnamedParameterUse.kt
index 756c7b15a1c6..cc3a9691efaa 100644
--- a/detekt-rules-errorprone/src/main/kotlin/dev/detekt/rules/bugs/UnnamedParameterUse.kt
+++ b/detekt-rules-errorprone/src/main/kotlin/dev/detekt/rules/bugs/UnnamedParameterUse.kt
@@ -120,6 +120,7 @@ class UnnamedParameterUse(config: Config) :
         analyze(expression) {
             val call = expression.resolveToCall()?.singleFunctionCallOrNull() ?: return
             val symbol = call.symbol
+            if (!symbol.hasStableParameterNames) return
             if (symbol.origin.let { it == KaSymbolOrigin.JAVA_SOURCE || it == KaSymbolOrigin.JAVA_LIBRARY }) return
             if (ignoreFunctionCall.any { it.match(symbol) }) return
 


Test patch:
diff --git a/detekt-rules-errorprone/src/test/kotlin/dev/detekt/rules/bugs/UnnamedParameterUseSpec.kt b/detekt-rules-errorprone/src/test/kotlin/dev/detekt/rules/bugs/UnnamedParameterUseSpec.kt
index 1cc7483bb34e..727c39ec977e 100644
--- a/detekt-rules-errorprone/src/test/kotlin/dev/detekt/rules/bugs/UnnamedParameterUseSpec.kt
+++ b/detekt-rules-errorprone/src/test/kotlin/dev/detekt/rules/bugs/UnnamedParameterUseSpec.kt
@@ -471,6 +471,46 @@ class UnnamedParameterUseSpec(private val env: KotlinEnvironmentContainer) {
         ).hasSize(1)
     }
 
+    @Test
+    fun `does not report for lambda invocation - #8601`() {
+        val code = """
+            class OnboardingPhoneNumberNavigator(
+                private val onNavigateToRequestPin: (String, String) -> Unit,
+            ) {
+                fun navigateToRequestPin(
+                    country: String,
+                    phoneNumber: String,
+                ) {
+                    onNavigateToRequestPin(country, phoneNumber)
+                }
+            }
+        """.trimIndent()
+
+        assertThat(
+            getSubject(allowAdjacentDifferentTypeParams = true).lintWithContext(env, code)
+        ).isEmpty()
+    }
+
+    @Test
+    fun `does not report for lambda invocation with named param`() {
+        val code = """
+            class OnboardingPhoneNumberNavigator(
+                private val onNavigateToRequestPin: (country: String, phoneNumber: String) -> Unit,
+            ) {
+                fun navigateToRequestPin(
+                    country: String,
+                    phoneNumber: String,
+                ) {
+                    onNavigateToRequestPin(country, phoneNumber)
+                }
+            }
+        """.trimIndent()
+
+        assertThat(
+            getSubject(allowAdjacentDifferentTypeParams = true).lintWithContext(env, code)
+        ).isEmpty()
+    }
+
     @Test
     fun `does report class constructor is called without name`() {
         val code = """