KT-64832 KT-61032 [FIR] Correctly handle extension receiver from implicit invoke calls in UnusedChecker

- use `FirImplicitInvokeCall` instance check to detect implicit calls,
it is cleaner than checking particular resolve type and "invoke" name
- reuse `visitQualifiedAccesses` to update the CFG instead of manually
searching through the `localProperties` (because it didn't work in the
case of overloads)

^KT-64832 Fixed
^KT-61032 Fixed
This commit is contained in:
Roman Golyshev
2024-01-09 17:04:41 +01:00
committed by Space Team
parent 0cad4c9632
commit c3a61f539b
8 changed files with 18 additions and 23 deletions
@@ -3,7 +3,7 @@ class Foo
operator fun Foo.invoke() {}
fun foo() {
val <!UNUSED_VARIABLE!>x<!> = Foo()
val x = Foo()
x()
}
@@ -3,7 +3,7 @@ class Foo {
}
fun foo() {
val <!UNUSED_VARIABLE!>x<!> = Foo()
val x = Foo()
x()
}
@@ -2,7 +2,7 @@
import kotlin.reflect.KFunction1
fun foo(action: KFunction1<String, Int>): Int {
val <!UNUSED_VARIABLE!>localAction<!> = action
val localAction = action
return localAction("hello")
}
@@ -2,7 +2,7 @@
fun foo(): Int {
fun action(s: String): Int = s.toInt()
val <!UNUSED_VARIABLE!>localAction<!> = ::action
val localAction = ::action
return localAction("hello")
}
@@ -2,7 +2,7 @@
import kotlin.reflect.KSuspendFunction1
suspend fun foo(action: KSuspendFunction1<String, Int>): Int {
val <!UNUSED_VARIABLE!>localAction<!> = action
val localAction = action
return localAction("hello")
}
@@ -1,8 +1,8 @@
fun foo() {
val x = fun(s: String) {}
val <!UNUSED_VARIABLE!>x<!> = fun(s: String) {}
fun nested() {
val <!UNUSED_VARIABLE!>x<!> = fun(i: Int) {}
val x = fun(i: Int) {}
x(10)
}
@@ -1,5 +1,5 @@
suspend fun foo(action: suspend () -> Unit) {
val <!UNUSED_VARIABLE!>x<!> = action
val x = action
x()
}