In order to work properly in HashMap/HashSet, UniqueType must have the property: forall t1, t2. equals(t1,t2) => hashCode(t1) == hashCode(t2) . This property doesn't hold.