Skip to content

Commit

Permalink
Adapt some implicit resolution change in 3.5
Browse files Browse the repository at this point in the history
There is a conflict between opaqueHandler and userIdOfWriter for UserId
Both are sastify for BSONWriter[UserId]. In this case of conflicting,
before 3.5 the compiler will pick the more specific type (in this case
opaqueHandler: BSONHandler[UserId] because it's more specific than
BSONWriter[UserId]). In 3.6 they will flip the priority, a.k.a pic the
most general. So, this specific case doesn't really affect us. But
removing implicit ambiguity is good anyway I guess.

More detail on the implicit resolution change here:
scala/scala3#19300
  • Loading branch information
lenguyenthanh committed Jul 6, 2024
1 parent f970239 commit 129b7da
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/db/src/main/Handlers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ trait Handlers:
given userIdOfWriter[U: UserIdOf, T](using writer: BSONWriter[UserId]): BSONWriter[U] with
inline def writeTry(u: U) = writer.writeTry(u.id)

given NoDbHandler[UserId] with {}
given userIdHandler: BSONHandler[UserId] = stringIsoHandler

given dateTimeHandler: BSONHandler[LocalDateTime] = quickHandler[LocalDateTime](
{ case v: BSONDateTime => millisToDateTime(v.value) },
v => BSONDateTime(v.toMillis)
Expand Down

0 comments on commit 129b7da

Please sign in to comment.