-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump scala 3.5.0 rc3 and adapt to new implicit resolution rules #15664
Conversation
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
With Writer is limited by NoDbHandler[T] but Reader is always available. This fixes situation like `UserName` which writer is provider by userIdOfWrite and only need Reader from opaque reader.
scalalib 11.2.3 published |
scalachess 16.0.9 is missing |
oops, I'll publish 16.0.9 |
0460bc9
to
9162681
Compare
@@ -23,6 +25,12 @@ case class UserLine( | |||
|
|||
def isLichess = userId.is(UserId.lichess) | |||
|
|||
object UserLine: | |||
private[chat] given BSONHandler[UserLine] = BSONStringHandler.as[UserLine]( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split this from Line
object, otherwise it'll be BSONHandler[UserLine]
and BSONHandler[Line]
are ambiguous.
|
||
given listHandler[T: BSONHandler]: BSONHandler[List[T]] with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From scala/scala3#19300, compiler will pick the most general given instance: https://github.com/scala/scala3/pull/19300/files#diff-b961213fc5ea62f83ece999f7275ee195fed5a57e4f1c4e6b39dc9d7232a7a90R169. So listHandler will never be picked over reactivemongo collectionWriter. Similar for vectorHandler
.
modules/db/src/main/Handlers.scala
Outdated
inline def writeTry(u: U) = writer.writeTry(u.id) | ||
|
||
given noOpaqueUserId[A: lila.core.userId.OpaqueUserId]: NoDbHandler[A] with {} | ||
given noUserIdOf[A: lila.core.userId.UserIdOf]: NoDbHandler[A] with {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This removing BSONWriter
instance for an
OpaqueUserId
is used to get BSONWriter
instance from UserIdOf
and as newtypes instance, which was fine before and should be fine in 3.6 as well but removing ambiguity is a good thing I guess.
@@ -108,18 +111,18 @@ trait Handlers: | |||
leftHandler.readTry(bson).map(Left.apply).orElse(rightHandler.readTry(bson).map(Right.apply)) | |||
def writeTry(e: Either[L, R]) = e.fold(leftHandler.writeTry, rightHandler.writeTry) | |||
|
|||
def stringMapHandler[V](using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reactivemongo provides mapWriter/Reader
and collectionWriter/Reader
which are both valid instance for Map[String, V]
, and now it is illegal in 3.6.
With new implement of mapHandler
We use mapWriter
and mapReader
directly which avoid the issue.
@@ -47,7 +47,7 @@ object BuildSettings { | |||
"-Ybackend-parallelism:16", // https://github.com/scala/scala3/pull/15392 | |||
// "-nowarn", // during migration | |||
// "-rewrite", | |||
// "-source:3.4-migration", | |||
"-source:3.6-migration", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is to avoid false positive warning: scala/scala3#21036, and force me to fix implicit ambiguity issue.
Use
-source:3.6-migration
to make sure We're compatible with implicit resolution changes which will happen in3.6
(in 3.5 compiler just emit (possibly false positive (ex: scala/scala3#21036) warnings.There are some changes in
db.Handlers
that are required the snippet below will not compiled due to: scala/scala3#19300required: lichess-org/scalalib#41
This is a draft version, I'll need to review and add more comment/context before merging.
Also please comment & review