@@ -1382,6 +1382,7 @@ object JsonCodecMaker {
13821382 def genWriteConstantVal (value : String , out : Expr [JsonWriter ])(using Quotes ): Expr [Unit ] =
13831383 if (isEncodingRequired(value)) ' { $out.writeVal($ {Expr (value)}) }
13841384 else ' { $out.writeNonEscapedAsciiVal($ {Expr (value)}) }
1385+
13851386 def genWriteArray [T : Type ](x : Expr [Iterable [T ]], writeVal : Quotes ?=> (Expr [JsonWriter ], Expr [T ]) => Expr [Unit ],
13861387 out : Expr [JsonWriter ])(using Quotes ): Expr [Unit ] = ' {
13871388 $out.writeArrayStart()
@@ -2600,7 +2601,7 @@ object JsonCodecMaker {
26002601 def cond (v : Expr [Array [_]])(using Quotes ): Expr [Boolean ] =
26012602 val da = d.asExprOf[Array [_]]
26022603 if (cfg.transientEmpty)
2603- ' { $v.length > 0 && ! $ {withEqualsFor(fTpe, v, da)((x1, x2) => genArrayEquals(fTpe, x1, x2))} }
2604+ ' { $v.length != 0 && ! $ {withEqualsFor(fTpe, v, da)((x1, x2) => genArrayEquals(fTpe, x1, x2))} }
26042605 else
26052606 ' { ! $ {withEqualsFor(fTpe, v, da)((x1, x2) => genArrayEquals(fTpe, x1, x2))} }
26062607
@@ -2618,7 +2619,7 @@ object JsonCodecMaker {
26182619 def cond (v : Expr [IArray [ft1]])(using Quotes ): Expr [Boolean ] =
26192620 val da = d.asExprOf[IArray [ft1]]
26202621 if (cfg.transientEmpty)
2621- ' { $v.length > 0 && ! $ {withEqualsFor(fTpe, v, da)((x1, x2) => genArrayEquals(fTpe, x1, x2))} }
2622+ ' { $v.length != 0 && ! $ {withEqualsFor(fTpe, v, da)((x1, x2) => genArrayEquals(fTpe, x1, x2))} }
26222623 else
26232624 ' { ! $ {withEqualsFor(fTpe, v, da)((x1, x2) => genArrayEquals(fTpe, x1, x2))} }
26242625
@@ -2662,7 +2663,7 @@ object JsonCodecMaker {
26622663 }
26632664 } else if (cfg.transientEmpty && fTpe <:< TypeRepr .of[Array [_]]) ' {
26642665 val v = $ {Select (x.asTerm, fieldInfo.getterOrField).asExprOf[ft & Array [_]]}
2665- if (v.length > 0 ) {
2666+ if (v.length != 0 ) {
26662667 $ {genWriteConstantKey(fieldInfo.mappedName, out)}
26672668 $ {genWriteVal(' v , fTpe :: types, fieldInfo.isStringified, None , out)}
26682669 }
@@ -2671,7 +2672,7 @@ object JsonCodecMaker {
26712672 fTpe1.asType match
26722673 case ' [ft1] => ' {
26732674 val v = $ {Select (x.asTerm, fieldInfo.getterOrField).asExprOf[IArray [ft1]]}
2674- if (v.length > 0 ) {
2675+ if (v.length != 0 ) {
26752676 $ {genWriteConstantKey(fieldInfo.mappedName, out)}
26762677 $ {genWriteVal(' v , fTpe :: types, fieldInfo.isStringified, None , out)}
26772678 }
0 commit comments