This is probably a stupid question but why does In...
# multiplatform
m
This is probably a stupid question but why does IntelliJ generate Java-dependent code in the commonMain part of a multi-platform project? You can find an example in the thread.
Copy code
class 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()
    }

}
mind blown 1
This is a simple test class with just one Double value in it. I generated the equals and hash code via IntelliJ. So I have two questions. Why is it using
javaClass
and why does it compile? I’d rather expect a line like this:
Copy code
if (other == null || this::class != other::class) return false
e
iirc kclass doesn't work for the synthetic classes generated at runtime for indy lambdas, not sure if that breaks this or not though
m
Well, in the end the
javaClass
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?