Skip to content

Commit 9cc7a30

Browse files
committed
Kotlin: do not report on unused object extension parameters
1 parent fbcf7ea commit 9cc7a30

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

java/ql/lib/semmle/code/java/deadcode/DeadCode.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,12 @@ class RootdefCallable extends Callable {
281281
Parameter unusedParameter() {
282282
exists(int i | result = this.getParameter(i) |
283283
not exists(result.getAnAccess()) and
284-
not overrideAccess(this, i)
284+
not overrideAccess(this, i) and
285+
// Do not report unused parameters on extension parameters that are (companion) objects.
286+
not (
287+
result.isExtensionParameter() and
288+
(result.getType() instanceof CompanionObject or result.getType() instanceof ClassObject)
289+
)
285290
)
286291
}
287292

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
| Test.kt:11:8:11:18 | a | The parameter 'a' is never used. |
22
| Test.kt:19:5:19:5 | <this> | The parameter '<this>' is never used. |
3-
| Test.kt:20:5:20:15 | <this> | The parameter '<this>' is never used. |
4-
| Test.kt:21:5:21:5 | <this> | The parameter '<this>' is never used. |

0 commit comments

Comments
 (0)