Michael Paus
01/25/2022, 3:29 PMMichael Paus
01/25/2022, 3:29 PMclass EqualsGenerationTest {
val x: Double = 0.0
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as EqualsGenerationTest
if (x != other.x) return false
return true
}
override fun hashCode(): Int {
return x.hashCode()
}
}
Michael Paus
01/25/2022, 3:31 PMjavaClass
and why does it compile?
I’d rather expect a line like this:
if (other == null || this::class != other::class) return false
ephemient
01/25/2022, 6:49 PMMichael Paus
01/26/2022, 7:32 PMjavaClass
did not compile (as expected). It was just the IntelliJ editor which did not complain about it. Nevertheless I still think this code should have never been generated this way or am I misunderstanding something?