Generate equals/hashCode(): Enable for classes without properties
Also: - forbid for enum classes - use javaClass.hashCode() instead of 0 if class has no properties #KT-18418 Fixed
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
open class X {
|
||||
override fun equals(other: Any?) = super.equals(other)
|
||||
override fun hashCode() = super.hashCode()
|
||||
}
|
||||
|
||||
class A : X() {
|
||||
fun foo() {
|
||||
|
||||
}
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (other?.javaClass != javaClass) return false
|
||||
if (!super.equals(other)) return false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return super.hashCode()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user