mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Merge pull request #10720 from tamasvajk/kotlin-equals-fix
Kotlin: Consider `::class` type check in `java/unchecked-cast-in-equals`
This commit is contained in:
@@ -30,6 +30,8 @@ predicate hasTypeTest(Variable v) {
|
||||
or
|
||||
any(SafeCastExpr sce).getExpr() = v.getAnAccess()
|
||||
or
|
||||
any(ClassExpr c).getExpr() = v.getAnAccess()
|
||||
or
|
||||
exists(MethodAccess ma |
|
||||
ma.getMethod().getName() = "getClass" and
|
||||
ma.getQualifier() = v.getAnAccess()
|
||||
|
||||
@@ -5,3 +5,9 @@ data class E(val x: Int) {
|
||||
return (other as? E)?.x == this.x
|
||||
}
|
||||
}
|
||||
|
||||
data class F(val x: Int) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return other != null && other::class == this::class
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user