Skip to content

Adjust Custom FromExpr[Option[A]] for Scala 3.8#355

Merged
kitlangton merged 1 commit intokitlangton:mainfrom
WojciechMazur:scala_3.8/fix_expr_from_option
Oct 24, 2025
Merged

Adjust Custom FromExpr[Option[A]] for Scala 3.8#355
kitlangton merged 1 commit intokitlangton:mainfrom
WojciechMazur:scala_3.8/fix_expr_from_option

Conversation

@WojciechMazur
Copy link
Copy Markdown
Contributor

Tweak to custom implementation of FromExpr[Option[A]] to make it compile under Scala 3.8. The type annotation is required to narrow A | Null into just A. Scala 3.8 would ship with standard library compiled using Scala 3 including some adjustments to signatures
Issue detected by Open Community Build - https://github.com/VirtusLab/community-build3/actions/runs/18606867633/job/53059126390

The issue is triggered because Option.apply is now defined as def apply[T](value: T | Null): Option[T] instead of def apply[T](value: T): Option[T]

Based on the current upstream implementation https://github.com/scala/scala3/blame/9ff48b1629601d6c7d4f766254180d917f2c7161/library/src/scala/quoted/FromExpr.scala#L100-L112

Note: I'm not sure if the rhs should probably be Some(Option(a)), or was a deliberate decision for this variant of FromExpr

@kitlangton
Copy link
Copy Markdown
Owner

Thanks, @WojciechMazur!

@kitlangton kitlangton merged commit e963be3 into kitlangton:main Oct 24, 2025
2 checks passed
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.

2 participants