Skip to content

fix 26026: restore type parameter of Option.orNull#26027

Open
olhotak wants to merge 1 commit into
scala:mainfrom
dotty-staging:option-ornull-fix
Open

fix 26026: restore type parameter of Option.orNull#26027
olhotak wants to merge 1 commit into
scala:mainfrom
dotty-staging:option-ornull-fix

Conversation

@olhotak
Copy link
Copy Markdown
Contributor

@olhotak olhotak commented May 9, 2026

Fixes #26026

How much have you relied on LLM-based tools in this contribution?

Not at all

How was the solution tested?

PR includes test from issue.

@olhotak olhotak requested a review from a team as a code owner May 9, 2026 12:30
@olhotak olhotak requested review from noti0na1, sjrd and soronpo May 9, 2026 12:30
@olhotak olhotak force-pushed the option-ornull-fix branch from 79a048d to ebef698 Compare May 9, 2026 12:38
@noti0na1
Copy link
Copy Markdown
Member

noti0na1 commented May 9, 2026

How about this version def orNull[A1 >: A]: A1 | Null?

@soronpo
Copy link
Copy Markdown
Contributor

soronpo commented May 9, 2026

I'm not familiar with the old behavior concept. Before this change, during runtime you would get ev(null). Now this change breaks that in runtime behavior for all previous code that expects ev(null) instead of null no?

@noti0na1
Copy link
Copy Markdown
Member

noti0na1 commented May 9, 2026

For the compiled old code, it will use the protected version, so it's fine. The source code which explicitly provides evidence will be rejected and need rewriten, as intended. For the ev call, it's just a cast in this case (turning null into A1).

@olhotak
Copy link
Copy Markdown
Contributor Author

olhotak commented May 9, 2026

How about this version def orNull[A1 >: A]: A1 | Null?

I think that would be OK too.

@olhotak olhotak changed the title Option ornull fix fix 26026: restore type parameter of Option.orNull May 9, 2026
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.

Regression: Option.orNull[T] no longer compiles after #25733 (3.9.0-nightly)

3 participants