mirror of
https://github.com/github/codeql.git
synced 2026-04-28 18:25:24 +02:00
Merge pull request #9150 from tamasvajk/kotlin-MissingInstanceofInEquals
Kotlin: Add more type check casts to MissingInstanceofInEquals query
This commit is contained in:
@@ -26,6 +26,10 @@ class CheckedCast extends CastExpr {
|
||||
predicate hasTypeTest(Variable v) {
|
||||
any(InstanceOfExpr ioe).getExpr() = v.getAnAccess()
|
||||
or
|
||||
any(NotInstanceOfExpr nioe).getExpr() = v.getAnAccess()
|
||||
or
|
||||
any(SafeCastExpr sce).getExpr() = v.getAnAccess()
|
||||
or
|
||||
exists(MethodAccess ma |
|
||||
ma.getMethod().getName() = "getClass" and
|
||||
ma.getQualifier() = v.getAnAccess()
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
Likely Bugs/Comparison/MissingInstanceofInEquals.ql
|
||||
@@ -0,0 +1,7 @@
|
||||
data class D(val x: Int) {}
|
||||
|
||||
data class E(val x: Int) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return (other as? E)?.x == this.x
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user