Daniel
11/28/2019, 7:05 PMsealed class TestClassParent(val any: Any) {
data class TestClassChild(val anyOther: Any) : TestClassParent(Any())
}
When I decompile this super.equals() seems to be not called in the TestClassChild:
public boolean equals(@Nullable Object var1) {
if (this != var1) {
if (var1 instanceof TestClassParent.TestClassChild) {
TestClassParent.TestClassChild var2 = (TestClassParent.TestClassChild)var1;
if (Intrinsics.areEqual(this.anyOther, var2.anyOther)) {
return true;
}
}
return false;
} else {
return true;
}
}
I don't know if you could construct a case where this matters, but at first glance it seems that the equals contract is broken
streetsofboston
11/28/2019, 8:07 PMTestClassParent
is not a data class
. For non-data classes, the only requirement for equality is that both references 'point' to the same instance (this == var1
in this snippet)