Kotlin: Add test case for ::class type check in equals

This commit is contained in:
Tamas Vajk
2022-10-07 09:22:06 +02:00
parent 0e6735b804
commit f7f12076df
2 changed files with 7 additions and 0 deletions

View File

@@ -0,0 +1 @@
| Test.kt:10:14:12:5 | equals | This 'equals()' method does not check argument type. |

View File

@@ -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
}
}