Skip to content

Commit 159df44

Browse files
authored
Add missing support of immutable.TreeSeqMap by Scala 3 macros
1 parent 91fd0b1 commit 159df44

File tree

1 file changed

+7
-1
lines changed
  • jsoniter-scala-macros/shared/src/main/scala-3/com/github/plokhotnyuk/jsoniter_scala/macros

1 file changed

+7
-1
lines changed

jsoniter-scala-macros/shared/src/main/scala-3/com/github/plokhotnyuk/jsoniter_scala/macros/JsonCodecMaker.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1744,6 +1744,10 @@ object JsonCodecMaker {
17441744
tpe <:< TypeRepr.of[mutable.CollisionProofHashMap[_, _]]) withNullValueFor(tpe) {
17451745
val tpe1 = typeArg1(tpe)
17461746
Apply(scalaMapEmptyNoArgs(tpe, tpe1, typeArg2(tpe)), List(summonOrdering(tpe1))).asExprOf[T]
1747+
} else if (tpe <:< TypeRepr.of[immutable.TreeSeqMap[_, _]]) withNullValueFor(tpe) {
1748+
(typeArg1(tpe).asType, typeArg2(tpe).asType) match
1749+
case ('[t1], '[t2]) =>
1750+
'{ immutable.TreeSeqMap.empty[t1, t2] }.asExprOf[T]
17471751
} else if (tpe <:< TypeRepr.of[immutable.Map[_, _]]) withNullValueFor(tpe) {
17481752
scalaMapEmptyNoArgs(tpe, typeArg1(tpe), typeArg2(tpe)).asExprOf[T]
17491753
} else if (tpe <:< TypeRepr.of[collection.Map[_, _]]) {
@@ -2379,10 +2383,12 @@ object JsonCodecMaker {
23792383
val tpe2 = typeArg2(tpe)
23802384
(tpe1.asType, tpe2.asType) match
23812385
case ('[t1], '[t2]) =>
2382-
val builderNoApply =
2386+
def builderNoApply =
23832387
TypeApply(Select.unique(scalaCollectionCompanion(tpe), "newBuilder"), List(TypeTree.of[t1], TypeTree.of[t2]))
2388+
23842389
val newBuilder =
23852390
(if (tpe <:< TypeRepr.of[collection.SortedMap[_, _]]) Apply(builderNoApply, List(summonOrdering(tpe1)))
2391+
else if (tpe <:< TypeRepr.of[immutable.TreeSeqMap[_, _]]) '{ immutable.TreeSeqMap.newBuilder[t1, t2] }.asTerm
23862392
else builderNoApply).asExprOf[mutable.Builder[(t1, t2), T & collection.Map[t1, t2]]]
23872393

23882394
def readVal2(using Quotes) =

0 commit comments

Comments
 (0)