Allow generate toString(), equals(), and hashCode() to include non-default accessors
^KT-15262 Fixed
This commit is contained in:
committed by
Vladimir Dolzhenko
parent
3bf18343f5
commit
af6e744b65
@@ -4,5 +4,8 @@ class Test {
|
||||
field = value.toUpperCase()
|
||||
}
|
||||
var name: String = ""
|
||||
val age by lazy { 15 + 10 }
|
||||
val color: String
|
||||
get() = "Purple"
|
||||
<caret>
|
||||
}
|
||||
+8
@@ -4,6 +4,10 @@ class Test {
|
||||
field = value.toUpperCase()
|
||||
}
|
||||
var name: String = ""
|
||||
val age by lazy { 15 + 10 }
|
||||
val color: String
|
||||
get() = "Purple"
|
||||
|
||||
<caret>override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
@@ -12,6 +16,8 @@ class Test {
|
||||
|
||||
if (serial != other.serial) return false
|
||||
if (name != other.name) return false
|
||||
if (age != other.age) return false
|
||||
if (color != other.color) return false
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -19,6 +25,8 @@ class Test {
|
||||
override fun hashCode(): Int {
|
||||
var result = serial.hashCode()
|
||||
result = 31 * result + name.hashCode()
|
||||
result = 31 * result + age
|
||||
result = 31 * result + color.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
+9
-1
@@ -8,11 +8,19 @@ class Test {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as Test
|
||||
|
||||
if (serial != other.serial) return false
|
||||
if (name != other.name) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return javaClass.hashCode()
|
||||
var result = serial.hashCode()
|
||||
result = 31 * result + name.hashCode()
|
||||
return result
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user