Kotlin: do not report on unused object extension parameters

This commit is contained in:
Tamas Vajk
2022-10-26 15:06:48 +02:00
parent fbcf7ea669
commit 9cc7a30a75
2 changed files with 6 additions and 3 deletions

View File

@@ -281,7 +281,12 @@ class RootdefCallable extends Callable {
Parameter unusedParameter() { Parameter unusedParameter() {
exists(int i | result = this.getParameter(i) | exists(int i | result = this.getParameter(i) |
not exists(result.getAnAccess()) and not exists(result.getAnAccess()) and
not overrideAccess(this, i) not overrideAccess(this, i) and
// Do not report unused parameters on extension parameters that are (companion) objects.
not (
result.isExtensionParameter() and
(result.getType() instanceof CompanionObject or result.getType() instanceof ClassObject)
)
) )
} }

View File

@@ -1,4 +1,2 @@
| Test.kt:11:8:11:18 | a | The parameter 'a' is never used. | | Test.kt:11:8:11:18 | a | The parameter 'a' is never used. |
| Test.kt:19:5:19:5 | <this> | The parameter '<this>' is never used. | | Test.kt:19:5:19:5 | <this> | The parameter '<this>' is never used. |
| Test.kt:20:5:20:15 | <this> | The parameter '<this>' is never used. |
| Test.kt:21:5:21:5 | <this> | The parameter '<this>' is never used. |