Skip to content

Commit fc614ad

Browse files
committed
Kotlin: Exclude .kt files from missing instanceof in equals query
1 parent c70f3d3 commit fc614ad

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

java/ql/src/Likely Bugs/Comparison/MissingInstanceofInEquals.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class UnimplementedEquals extends EqualsMethod {
6464

6565
from EqualsMethod m
6666
where
67+
m.getFile().isJavaSourceFile() and
6768
exists(m.getBody()) and
6869
exists(Parameter p | p = m.getAParameter() |
6970
// The parameter has no type test

java/ql/test/kotlin/query-tests/MissingInstanceofInEquals/Test.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,9 @@ data class G(val x: Int) {
1717
return other != null && other.javaClass == this.javaClass
1818
}
1919
}
20+
21+
data class H(val x: Int) {
22+
override fun equals(other: Any?): Boolean {
23+
return other != null
24+
}
25+
}

0 commit comments

Comments
 (0)