scala/scala — pull request #1041 by bhuber (2012-08-02 19:37:11+00:00)
Title: Issue/6153

This is my patch for the BigDecimal.hashCode bug, as discussed at https://issues.scala-lang.org/browse/SI-6153 . I'm quite new to Scala, so any suggestions for improvement are welcome. Some things it fixes:
* BigDecimal still returns same hashCode for equivalent values (e.g. "2" and "2.00")
* BigInt and BigDecimal now return same hashCode for equivalent values
* BigDecimal returns same hashCode as for equivalent Int, Long, and
Double values
* BigDecimal hashCodes are no longer "stratified", as discussed in the original bug report
* Although the new version is more expensive to compute than the old, the result is saved so it only has to be computed once

It's worth noting that since this changes the hashCode algorithms for BigInt and BigDecimal, it could break serialized data structures that rely on them (e.g. if someone serializes a hash table from an old version of Scala and tries to load it into a new one, it may cause problems).

--Bennet Huber