Skip to content

Commit 150bf63

Browse files
authored
Merge pull request AVSystem#770 from AVSystem/update/scala-compiler-2.13.18
Update Scala to 2.13.18
2 parents 4bbde20 + f3209d9 commit 150bf63

File tree

6 files changed

+30
-15
lines changed

6 files changed

+30
-15
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
fail-fast: false
2626
matrix:
2727
os: [ubuntu-latest]
28-
scala: [2.13.16]
28+
scala: [2.13.18]
2929
java: [temurin@17, temurin@21, temurin@25]
3030
runs-on: ${{ matrix.os }}
3131
steps:
@@ -83,7 +83,7 @@ jobs:
8383
strategy:
8484
matrix:
8585
os: [ubuntu-latest]
86-
scala: [2.13.16]
86+
scala: [2.13.18]
8787
java: [temurin@17]
8888
runs-on: ${{ matrix.os }}
8989
steps:

macros/src/main/scala/com/avsystem/commons/macros/MacroCommons.scala

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,18 @@ trait MacroCommons extends CompatMacroCommons { bundle =>
234234
primaryConstructorOf(clsTpe).typeSignatureIn(clsTpe)
235235
}
236236

237+
private def isDefaultAnnotArg(tree: Tree): Boolean = {
238+
(tree.tpe match {
239+
case AnnotatedType(annots, _) => annots.exists(_.tree.tpe.typeSymbol.name.toString == "defaultArg")
240+
case _ => false
241+
}) ||
242+
tree.symbol != null && tree.symbol.isSynthetic && tree.symbol.name.decodedName.toString.contains("$default$")
243+
}
244+
237245
lazy val treeRes: Res[Tree] = annotTree match {
238246
case Apply(constr, args) =>
239247
val newArgs = (args zip constructorSig.paramLists.head) map {
240-
case (arg, param) if param.asTerm.isParamWithDefault && arg.symbol != null &&
241-
arg.symbol.isSynthetic && arg.symbol.name.decodedName.toString.contains("$default$") =>
248+
case (arg, param) if param.asTerm.isParamWithDefault && isDefaultAnnotArg(arg) =>
242249
if (findAnnotation(param, DefaultsToNameAT).nonEmpty)
243250
Ok(q"${subject.name.decodedName.toString}")
244251
else
@@ -283,6 +290,7 @@ trait MacroCommons extends CompatMacroCommons { bundle =>
283290
.collectFirst {
284291
case (param, arg) if param.name == subSym.name => arg match {
285292
case Literal(Constant(value: T)) => value
293+
case _ if param.asTerm.isParamWithDefault && isDefaultAnnotArg(arg) => whenDefault
286294
case t if param.asTerm.isParamWithDefault && t.symbol.isSynthetic &&
287295
t.symbol.name.decodedName.toString.contains("$default$") => whenDefault
288296
case t if classTag[T] == classTag[Tree] => t.asInstanceOf[T]
@@ -823,6 +831,7 @@ trait MacroCommons extends CompatMacroCommons { bundle =>
823831
case class LitOrDefault[T: ClassTag](default: T) {
824832
def unapply(tree: Tree): Option[T] = tree match {
825833
case Literal(Constant(value: T)) => Some(value)
834+
case _ if tree.tpe != null && tree.tpe.toString.endsWith("@scala.annotation.meta.defaultArg") => Some(default)
826835
case Select(_, TermName(n)) if n.startsWith("$lessinit$greater$default$") => Some(default)
827836
case _ => None
828837
}
@@ -1394,7 +1403,7 @@ trait MacroCommons extends CompatMacroCommons { bundle =>
13941403
// while typechecking case body and not after that. Therefore we need a macro which will inject itself exactly
13951404
// into that moment.
13961405
val fakeMatch =
1397-
q"""
1406+
q"""
13981407
import scala.language.experimental.macros
13991408
def $normName(tpref: $StringCls, value: $ScalaPkg.Any): $ScalaPkg.Any =
14001409
macro $CommonsPkg.macros.misc.WhiteMiscMacros.normalizeGadtSubtype

mongo/jvm/src/main/scala/com/avsystem/commons/mongo/typed/TypedMongoClient.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,14 @@ class TypedMongoClient(
5757
def listDatabaseNames: Observable[String] =
5858
multi(optionalizeFirstArg(nativeClient.listDatabaseNames(sessionOrNull)))
5959

60-
def listDatabases: Observable[Document] =
60+
@deprecated("Use listTypedDatabases or listRawDatabases instead", "2.25.0")
61+
def listDatabases: Observable[Nothing] = ???
62+
63+
def listRawDatabases: Observable[Document] =
6164
multi(optionalizeFirstArg(nativeClient.listDatabases(sessionOrNull)))
6265

63-
def listDatabases[T: GenCodec]: Observable[T] =
64-
listDatabases.map(doc => BsonValueInput.read[T](doc.toBsonDocument))
66+
def listTypedDatabases[T: GenCodec]: Observable[T] =
67+
listRawDatabases.map(doc => BsonValueInput.read[T](doc.toBsonDocument))
6568

6669
//TODO: `watch` methods
6770

mongo/jvm/src/main/scala/com/avsystem/commons/mongo/typed/TypedMongoDatabase.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,14 @@ class TypedMongoDatabase(
4747
def listCollectionNames: Observable[String] =
4848
multi(optionalizeFirstArg(nativeDatabase.listCollectionNames(sessionOrNull)))
4949

50-
def listCollections: Observable[Document] =
50+
@deprecated("Use listTypedCollections or listRawCollections instead", "2.25.0")
51+
def listDatabases: Observable[Nothing] = ???
52+
53+
def listRawCollections: Observable[Document] =
5154
multi(optionalizeFirstArg(nativeDatabase.listCollections(sessionOrNull)))
5255

53-
def listCollections[T: GenCodec]: Observable[T] =
54-
listCollections.map(doc => BsonValueInput.read[T](doc.toBsonDocument))
56+
def listTypedCollections[T: GenCodec]: Observable[T] =
57+
listRawCollections.map(doc => BsonValueInput.read[T](doc.toBsonDocument))
5558

5659
def createCollection(
5760
name: String,

project/Commons.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ object Commons extends ProjectGroup("commons") {
6565
Developer("ddworak", "Dawid Dworak", "[email protected]", url("https://github.com/ddworak")),
6666
),
6767

68-
scalaVersion := "2.13.16",
68+
scalaVersion := "2.13.18",
6969

7070
githubWorkflowTargetTags ++= Seq("v*"),
7171
githubWorkflowArtifactUpload := false,

redis/src/main/scala/com/avsystem/commons/redis/commands/ReplyDecoders.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,10 +303,10 @@ object ReplyDecoders {
303303
}
304304

305305
val multiBulkAsXConsumerInfo: ReplyDecoder[XConsumerInfo] =
306-
flatMultiBulkAsMap(bulkAsUTF8, undecoded).andThen(XConsumerInfo.apply)
306+
flatMultiBulkAsMap(bulkAsUTF8, undecoded).andThen(XConsumerInfo.apply _)
307307

308308
val multiBulkAsXGroupInfo: ReplyDecoder[XGroupInfo] =
309-
flatMultiBulkAsMap(bulkAsUTF8, undecoded).andThen(XGroupInfo.apply)
309+
flatMultiBulkAsMap(bulkAsUTF8, undecoded).andThen(XGroupInfo.apply _)
310310

311311
def multiBulkAsXStreamInfoOf[Rec: RedisRecordCodec]: ReplyDecoder[XStreamInfo[Rec]] =
312312
flatMultiBulkAsMap(bulkAsUTF8, undecoded).andThen(XStreamInfo[Rec](_))
@@ -374,7 +374,7 @@ object ReplyDecoders {
374374
flatMultiBulkAsMap(bulkAs[A], bulkAs[B])
375375

376376
def flatMultiBulkAsRecord[R: RedisRecordCodec]: ReplyDecoder[R] = {
377-
case ArrayMsg(elements: IndexedSeq[BulkStringMsg@unchecked]) if elements.forall(_.isInstanceOf[BulkStringMsg]) =>
377+
case ArrayMsg(elements: IndexedSeq[BulkStringMsg @unchecked]) if elements.forall(_.isInstanceOf[BulkStringMsg]) =>
378378
RedisRecordCodec[R].read(elements)
379379
}
380380

0 commit comments

Comments
 (0)