Skip to content

Commit 180fbb7

Browse files
committed
Clean up isValueClass check for Scala 3 macros
1 parent 09e65b8 commit 180fbb7

File tree

1 file changed

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

1 file changed

+5
-6
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -779,12 +779,12 @@ object JsonCodecMaker {
779779

780780
def isGenericTuple(tpe: TypeRepr): Boolean = tpe match {
781781
case AppliedType(tTpe, _) if tTpe =:= TypeRepr.of[*:] => true
782-
case _ => false
782+
case _ => false
783783
}
784784

785785
def genericTupleTypeArgs(tpe: TypeRepr): List[TypeRepr] = tpe match {
786786
case AppliedType(_, List(typeArg, tail)) => typeArg.dealias :: genericTupleTypeArgs(tail)
787-
case _ => Nil
787+
case _ => Nil
788788
}
789789

790790
def valueClassValueSymbol(tpe: TypeRepr): Symbol = tpe.typeSymbol.fieldMembers.head
@@ -1100,9 +1100,8 @@ object JsonCodecMaker {
11001100
})
11011101
})
11021102

1103-
def isValueClass(tpe: TypeRepr): Boolean = !isConstType(tpe) &&
1104-
(cfg.inlineOneValueClasses && isNonAbstractScalaClass(tpe) && !isCollection(tpe) && getClassInfo(tpe).fields.size == 1 ||
1105-
tpe <:< TypeRepr.of[AnyVal] && !tpe.classSymbol.fold(false)(x => defn.ScalaPrimitiveValueClasses.contains(x)))
1103+
def isValueClass(tpe: TypeRepr): Boolean = !isConstType(tpe) && isNonAbstractScalaClass(tpe) &&
1104+
(tpe <:< TypeRepr.of[AnyVal] || cfg.inlineOneValueClasses && !isCollection(tpe) && getClassInfo(tpe).fields.size == 1)
11061105

11071106
def adtChildren(tpe: TypeRepr): Seq[TypeRepr] = {
11081107
def resolveParentTypeArg(child: Symbol, fromNudeChildTarg: TypeRepr, parentTarg: TypeRepr,
@@ -2702,7 +2701,7 @@ object JsonCodecMaker {
27022701
case '[ft] =>
27032702
fDefault match {
27042703
case Some(d) =>
2705-
if (cfg.transientEmpty && fTpe <:< TypeRepr.of[Iterable[_]] ) '{
2704+
if (cfg.transientEmpty && fTpe <:< TypeRepr.of[Iterable[_]]) '{
27062705
val v = ${Select(x.asTerm, fieldInfo.getterOrField).asExprOf[ft & Iterable[_]]}
27072706
if (!v.isEmpty && v != ${d.asExprOf[ft]}) {
27082707
${genWriteConstantKey(fieldInfo.mappedName, out)}

0 commit comments

Comments
 (0)