Skip to content

Modify rule for nullable union types in generic signatures#24129

Merged
noti0na1 merged 2 commits intoscala:mainfrom
dotty-staging:fix-generic-sig-ornull
Oct 6, 2025
Merged

Modify rule for nullable union types in generic signatures#24129
noti0na1 merged 2 commits intoscala:mainfrom
dotty-staging:fix-generic-sig-ornull

Conversation

@noti0na1
Copy link
Copy Markdown
Member

@noti0na1 noti0na1 commented Oct 3, 2025

No description provided.

@noti0na1 noti0na1 marked this pull request as ready for review October 3, 2025 20:18
if tpStripped ne tpWiden then tpStripped else tp

if ctx.explicitNulls then strip(self) else self
strip(self)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems suspicious. Without ctx.explictNulls, isn't T|Null generally meant to be equivalent to T?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I want to make it as a general type operation, and I think it is fine to actually strip at most use places of stripNull. If we really want to be safe and distinguish the explictNulls case, we should add the check before use.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I double-checked all places of stripNull and OrNull, I think the guards I added should be enough.

builder.append(')')
methodResultSig(rte)

case OrNull(tp1) if !tp1.derivesFrom(defn.AnyValClass) =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable but I don't know enough about erasure overall and signature generation to be able to say whether it could break anything. Perhaps @smarter could more confidently comment on this change.

@noti0na1 noti0na1 merged commit 71fcd1a into scala:main Oct 6, 2025
49 checks passed
@noti0na1 noti0na1 deleted the fix-generic-sig-ornull branch October 6, 2025 13:04
@WojciechMazur WojciechMazur added this to the 3.8.0 milestone Oct 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants