Sealed sub-class -> object: handle equals, suggest "add equals"
Before this commit, sealed sub-class without state was considered a style issue. After this commit, sealed sub-class without state AND custom equals is considered a probable bug, because comparison of its instances is very fragile. Alternative fix (generate equals & hashCode by identity) is added.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<html>
|
||||
<body>
|
||||
This inspection reports direct inheritors of <b>sealed class</b> that have no state and thus can be objects.
|
||||
This inspection reports direct inheritors of <b>sealed class</b> that have no state and no overridden <b>equals</b>.
|
||||
It's highly recommended to override <b>equals</b> to provide comparison stability or convert <b>class</b> to <b>object</b> with the same effect.
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user