Skip to content

Avoid NPE when calling hashCode on a value class wrapping null#25110

Merged
lrytz merged 1 commit intoscala:mainfrom
lrytz:t7396
Jan 27, 2026
Merged

Avoid NPE when calling hashCode on a value class wrapping null#25110
lrytz merged 1 commit intoscala:mainfrom
lrytz:t7396

Conversation

@lrytz
Copy link
Copy Markdown
Member

@lrytz lrytz commented Jan 26, 2026

Change the synthetic hashCode for value classes from

def hashCode(): Int = this.underlying.hashCode

to

def hashCode(): Int = java.util.Objects.hashCode(this.underlying)

(unless the underlying value is primitive)

Forward-port of scala/scala#11204

Change the synthetic hashCode for value classes from

  def hashCode(): Int = this.underlying.hashCode

to

  def hashCode(): Int = java.util.Objects.hashCode(this.underlying)

(unless the underlying value is primitive)

Forward-port of scala/scala#11204
@lrytz lrytz merged commit 4616b66 into scala:main Jan 27, 2026
56 checks passed
@WojciechMazur WojciechMazur added the backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it. label Feb 3, 2026
@WojciechMazur WojciechMazur added this to the 3.8.2 milestone Feb 3, 2026
@WojciechMazur WojciechMazur added backport:accepted This PR needs to be backported, once it's been backported replace this tag by "backport:done" and removed backport:nominated If we agree to backport this PR, replace this tag with "backport:accepted", otherwise delete it. labels Feb 4, 2026
WojciechMazur added a commit that referenced this pull request Feb 5, 2026
…ull" to 3.8.2 (#25192)

Backports #25110 to the 3.8.2-RC2.

PR submitted by the release tooling.
[skip ci]
@WojciechMazur WojciechMazur added backport:done This PR was successfully backported. and removed backport:accepted This PR needs to be backported, once it's been backported replace this tag by "backport:done" labels Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:done This PR was successfully backported.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants