Skip to content

change lower bound of Option.orNull to nullable#25733

Open
olhotak wants to merge 1 commit intoscala:mainfrom
dotty-staging:option-ornull
Open

change lower bound of Option.orNull to nullable#25733
olhotak wants to merge 1 commit intoscala:mainfrom
dotty-staging:option-ornull

Conversation

@olhotak
Copy link
Copy Markdown
Contributor

@olhotak olhotak commented Apr 8, 2026

This PR changes the signature of Option.orNull from

  @inline final def orNull[A1 >: A](implicit ev: Null <:< A1): A1 = this getOrElse ev(null)

to

  @inline final def orNull[A1 >: A | Null](implicit ev: Null <:< A1): A1 = this getOrElse ev(null)

Under -Yexplicit-nulls, type inference sometimes infers A1 to be a non-null type, leading to a failure to find the implicit ev. Changing the lower bound guides type inference to infer a nullable type.

Without -Yexplicit-nulls, the lower bounds A and A | Null are equivalent.

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

No.

How was the solution tested?

Added test option-ornull minimized from akka-management.

Additional notes

This may have to wait until a version when we can start making changes to standard library signatures.

@olhotak olhotak requested a review from a team as a code owner April 8, 2026 14:29
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.

1 participant