Scala Programming Language
  1. Scala Programming Language
  2. SI-4752

Hash code for None changes across JVM invocations

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.9.0
    • Fix Version/s: None
    • Component/s: Misc Compiler
    • Labels:
      None

      Description

      The hashCode for None changes across JVM invocations. This is because the hashCode method is not generated for case objects, so it uses the default java.lang.Object.hashCode implementation. case objects should have a hashCode method generated like is done for case classes.

      Related: SI-1387

        Activity

        Hide
        Commit Message Bot added a comment -

        (extempore in r25215) Stable hashCodes for case objects.
        Somehow case objects fell through the cracks and have had
        default hashCode implementations, leading to new hashCodes on
        each jvm run. Now we use the productPrefix, and inline it
        right into the bytecode.

        scala> None.## == "None".##
        res0: Boolean = true

        Closes #4752, no review.

        Show
        Commit Message Bot added a comment - (extempore in r25215 ) Stable hashCodes for case objects. Somehow case objects fell through the cracks and have had default hashCode implementations, leading to new hashCodes on each jvm run. Now we use the productPrefix, and inline it right into the bytecode. scala> None.## == "None".## res0: Boolean = true Closes #4752, no review.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Mark Harrah
          • Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development