Skip to content

Commit 14f54a4

Browse files
authored
Fixed reusing empty instances when reading of mutable.LongMap, collection.SortedMap, and mutable.CollisionProofHashMap collections
1 parent 737f10d commit 14f54a4

File tree

1 file changed

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

1 file changed

+6
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,13 +1722,11 @@ object JsonCodecMaker {
17221722
else if (tpe =:= TypeRepr.of[java.lang.Double]) '{ java.lang.Double.valueOf(0d) }.asExprOf[T]
17231723
else if (isOption(tpe, types.tail)) '{ None }.asExprOf[T]
17241724
else if (tpe <:< TypeRepr.of[mutable.BitSet]) '{ new mutable.BitSet }.asExprOf[T]
1725-
else if (tpe <:< TypeRepr.of[immutable.BitSet]) withNullValueFor(tpe)('{ immutable.BitSet.empty }.asExprOf[T])
1726-
else if (tpe <:< TypeRepr.of[collection.BitSet]) withNullValueFor(tpe)('{ collection.BitSet.empty }.asExprOf[T])
1725+
else if (tpe <:< TypeRepr.of[collection.BitSet]) withNullValueFor(tpe)('{ immutable.BitSet.empty }.asExprOf[T])
17271726
else if (tpe <:< TypeRepr.of[::[_]]) {
17281727
typeArg1(tpe).asType match
17291728
case '[t1] => '{ (null: ::[t1]) }.asExprOf[T]
1730-
}
1731-
else if (tpe <:< TypeRepr.of[List[_]] || tpe.typeSymbol == TypeRepr.of[Seq[_]].typeSymbol) '{ Nil }.asExprOf[T]
1729+
} else if (tpe <:< TypeRepr.of[List[_]] || tpe.typeSymbol == TypeRepr.of[Seq[_]].typeSymbol) '{ Nil }.asExprOf[T]
17321730
else if (tpe <:< TypeRepr.of[collection.SortedSet[_]] || tpe <:< TypeRepr.of[mutable.PriorityQueue[_]]) {
17331731
val tpe1 = typeArg1(tpe)
17341732
Apply(scalaCollectionEmptyNoArgs(tpe, tpe1), List(summonOrdering(tpe1))).asExprOf[T]
@@ -1737,11 +1735,11 @@ object JsonCodecMaker {
17371735
val tpe1 = typeArg1(tpe)
17381736
Apply(scalaCollectionEmptyNoArgs(tpe, tpe1), List(summonClassTag(tpe1))).asExprOf[T]
17391737
} else if (tpe <:< TypeRepr.of[immutable.IntMap[_]] || tpe <:< TypeRepr.of[immutable.LongMap[_]] ||
1740-
tpe <:< TypeRepr.of[mutable.LongMap[_]] || tpe <:< TypeRepr.of[immutable.Seq[_]] ||
1741-
tpe <:< TypeRepr.of[Set[_]]) withNullValueFor(tpe) {
1738+
tpe <:< TypeRepr.of[immutable.Seq[_]] || tpe <:< TypeRepr.of[immutable.Set[_]]) withNullValueFor(tpe) {
17421739
scalaCollectionEmptyNoArgs(tpe, typeArg1(tpe)).asExprOf[T]
1743-
} else if (tpe <:< TypeRepr.of[collection.SortedMap[_, _]] ||
1744-
tpe <:< TypeRepr.of[mutable.CollisionProofHashMap[_, _]]) withNullValueFor(tpe) {
1740+
} else if (tpe <:< TypeRepr.of[mutable.LongMap[_]]) scalaCollectionEmptyNoArgs(tpe, typeArg1(tpe)).asExprOf[T]
1741+
else if (tpe <:< TypeRepr.of[collection.SortedMap[_, _]] ||
1742+
tpe <:< TypeRepr.of[mutable.CollisionProofHashMap[_, _]]) {
17451743
val tpe1 = typeArg1(tpe)
17461744
Apply(scalaMapEmptyNoArgs(tpe, tpe1, typeArg2(tpe)), List(summonOrdering(tpe1))).asExprOf[T]
17471745
} else if (tpe <:< TypeRepr.of[immutable.TreeSeqMap[_, _]]) withNullValueFor(tpe) {

0 commit comments

Comments
 (0)