🎯 Goal
Affected version: 5.2.0
In the types from org.kotools.types.number package (Decimal, Integer, NonNegativeInteger, NonPositiveInteger, NonZeroInteger), the documentation of the hashCode function states the following:
This function follows the contract of Any.hashCode, with an additional property: if two instances are not equal, then calling this function on these objects must produce different hash codes.
This claim can't be satisfied mathematically. Int is a bounded type on 32-bit: collisions can occur. Here's an example:
// On Kotlin/JVM platform:
"Aa".hashCode() == "BB".hashCode()
The fix is to only guaranty that the implementation satisfies only the contract of Any.hashCode, not more, not less.
✅ Checklist
🎯 Goal
In the types from
org.kotools.types.numberpackage (Decimal,Integer,NonNegativeInteger,NonPositiveInteger,NonZeroInteger), the documentation of thehashCodefunction states the following:This claim can't be satisfied mathematically.
Intis a bounded type on 32-bit: collisions can occur. Here's an example:The fix is to only guaranty that the implementation satisfies only the contract of
Any.hashCode, not more, not less.✅ Checklist