@@ -763,9 +763,9 @@ object JsonCodecMaker {
763
763
764
764
def isTuple (tpe : TypeRepr ): Boolean = tpe <:< TypeRepr .of[Tuple ]
765
765
766
- def valueClassValueSymbol (tpe : TypeRepr ): Symbol = tpe.typeSymbol.fieldMembers( 0 )
766
+ def valueClassValueSymbol (tpe : TypeRepr ): Symbol = tpe.typeSymbol.fieldMembers.head
767
767
768
- def valueClassValueType (tpe : TypeRepr ): TypeRepr = tpe.memberType(tpe.typeSymbol.fieldMembers( 0 )).dealias
768
+ def valueClassValueType (tpe : TypeRepr ): TypeRepr = tpe.memberType(valueClassValueSymbol(tpe )).dealias
769
769
770
770
def isNonAbstractScalaClass (tpe : TypeRepr ): Boolean = tpe.classSymbol.fold(false ) { sym =>
771
771
val flags = sym.flags
@@ -788,9 +788,10 @@ object JsonCodecMaker {
788
788
def isOption (tpe : TypeRepr , types : List [TypeRepr ]): Boolean = tpe <:< TypeRepr .of[Option [_]] &&
789
789
(cfg.skipNestedOptionValues || ! types.headOption.exists(_ <:< TypeRepr .of[Option [_]]))
790
790
791
- def isCollection (tpe : TypeRepr ): Boolean =
792
- tpe <:< TypeRepr .of[Iterable [_]] || tpe <:< TypeRepr .of[Iterator [_]] || tpe <:< TypeRepr .of[Array [_]] ||
793
- tpe.typeSymbol.fullName == " scala.IArray$package$.IArray"
791
+ def isIArray (tpe : TypeRepr ): Boolean = tpe.typeSymbol.fullName == " scala.IArray$package$.IArray"
792
+
793
+ def isCollection (tpe : TypeRepr ): Boolean = tpe <:< TypeRepr .of[Iterable [_]] || tpe <:< TypeRepr .of[Iterator [_]] ||
794
+ tpe <:< TypeRepr .of[Array [_]] || isIArray(tpe)
794
795
795
796
def isJavaEnum (tpe : TypeRepr ): Boolean = tpe <:< TypeRepr .of[java.lang.Enum [_]]
796
797
@@ -1121,7 +1122,7 @@ object JsonCodecMaker {
1121
1122
case AppliedType (base, _) => base.appliedTo(ctArgs)
1122
1123
case AnnotatedType (AppliedType (base, _), annot) => AnnotatedType (base.appliedTo(ctArgs), annot)
1123
1124
case _ => polyRes.appliedTo(ctArgs)
1124
- case other => fail(s " Primary constructior for ${tpe.show} is not MethodType or PolyType but $other" )
1125
+ case other => fail(s " Primary constructor for ${tpe.show} is not MethodType or PolyType but $other" )
1125
1126
} else if (sym.isTerm) Ref (sym).tpe
1126
1127
else fail(" Only concrete (no free type parametes) Scala classes & objects are supported for ADT leaf classes. " +
1127
1128
s " Please consider using of them for ADT with base ' ${tpe.show}' or provide a custom implicitly accessible codec for the ADT base. " )
@@ -1627,7 +1628,7 @@ object JsonCodecMaker {
1627
1628
}
1628
1629
})
1629
1630
}
1630
- } else if (tpe1.typeSymbol.fullName == " scala.IArray$package$.IArray " ) {
1631
+ } else if (isIArray( tpe1) ) {
1631
1632
tpe1.asType match
1632
1633
case ' [t1] =>
1633
1634
val x1 = x1t.asExprOf[IArray [t1]]
@@ -1646,7 +1647,7 @@ object JsonCodecMaker {
1646
1647
}
1647
1648
})
1648
1649
}
1649
- } else if (tpe.typeSymbol.fullName == " scala.IArray$package$.IArray " ) {
1650
+ } else if (isIArray( tpe) ) {
1650
1651
if (tpe1 =:= TypeRepr .of[AnyRef ]) {
1651
1652
' { IArray .equals($ {x1t.asExprOf[IArray [AnyRef ]]}, $ {x2t.asExprOf[IArray [AnyRef ]]}) }
1652
1653
} else {
@@ -1785,7 +1786,7 @@ object JsonCodecMaker {
1785
1786
} else if (tpe <:< TypeRepr .of[Array [_]]) withNullValueFor(tpe) {
1786
1787
typeArg1(tpe).asType match
1787
1788
case ' [t1] => genNewArray[t1](' { 0 }).asExprOf[T ]
1788
- } else if (tpe.typeSymbol.fullName == " scala.IArray$package$.IArray " ) withNullValueFor(tpe) {
1789
+ } else if (isIArray( tpe) ) withNullValueFor(tpe) {
1789
1790
typeArg1(tpe).asType match
1790
1791
case ' [t1] => ' { IArray .unsafeFromArray($ {genNewArray[t1](' { 0 })}) }.asExprOf[T ]
1791
1792
} else if (isConstType(tpe)) {
@@ -2255,8 +2256,7 @@ object JsonCodecMaker {
2255
2256
}
2256
2257
}.asExprOf[T ]
2257
2258
} else if (decodeMethodSym.isDefined) Apply (Ref (decodeMethodSym.get), List (in.asTerm, default.asTerm)).asExprOf[T ]
2258
- else if (tpe <:< TypeRepr .of[Array [_]] || tpe <:< TypeRepr .of[immutable.ArraySeq [_]] ||
2259
- tpe.typeSymbol.fullName == " scala.IArray$package$.IArray" ||
2259
+ else if (tpe <:< TypeRepr .of[Array [_]] || tpe <:< TypeRepr .of[immutable.ArraySeq [_]] || isIArray(tpe) ||
2260
2260
tpe <:< TypeRepr .of[mutable.ArraySeq [_]]) withDecoderFor(methodKey, default, in) { (in, default) =>
2261
2261
val tpe1 = typeArg1(tpe)
2262
2262
val newArrayOnChange = tpe1 match
@@ -2300,7 +2300,7 @@ object JsonCodecMaker {
2300
2300
if ($i != $l) $ {Assign (x.asTerm, shrinkArray(x, i).asTerm).asExprOf[Unit ]}
2301
2301
mutable.ArraySeq .make[t1]($x)
2302
2302
}.asExprOf[mutable.ArraySeq [t1]], in).asExprOf[T ]
2303
- } else if (tpe.typeSymbol.fullName == " scala.IArray$package$.IArray " ) {
2303
+ } else if (isIArray( tpe) ) {
2304
2304
genReadArray(l => genNewArray[t1](l), (x, i, l) => ' {
2305
2305
if ($i == $l) {
2306
2306
$ {Assign (l.asTerm, ' { $l << 1 }.asTerm).asExprOf[Unit ]}
@@ -2701,7 +2701,7 @@ object JsonCodecMaker {
2701
2701
$ {genWriteVal(' v , fTpe :: types, fieldInfo.isStringified, None , out)}
2702
2702
}
2703
2703
}
2704
- } else if (fTpe.typeSymbol.fullName == " scala.IArray$package$.IArray " ) {
2704
+ } else if (isIArray( fTpe) ) {
2705
2705
val fTpe1 = typeArg1(fTpe)
2706
2706
fTpe1.asType match
2707
2707
case ' [ft1] => {
@@ -2756,7 +2756,7 @@ object JsonCodecMaker {
2756
2756
$ {genWriteConstantKey(fieldInfo.mappedName, out)}
2757
2757
$ {genWriteVal(' v , fTpe :: types, fieldInfo.isStringified, None , out)}
2758
2758
}
2759
- } else if (cfg.transientEmpty && fTpe.typeSymbol.fullName == " scala.IArray$package$.IArray " ) {
2759
+ } else if (cfg.transientEmpty && isIArray( fTpe) ) {
2760
2760
val fTpe1 = typeArg1(fTpe)
2761
2761
fTpe1.asType match
2762
2762
case ' [ft1] => ' {
@@ -2894,8 +2894,7 @@ object JsonCodecMaker {
2894
2894
else $out.writeNull()
2895
2895
}
2896
2896
} else if (encodeMethodSym.isDefined) Apply (Ref (encodeMethodSym.get), List (m.asTerm, out.asTerm)).asExprOf[Unit ]
2897
- else if (tpe <:< TypeRepr .of[Array [_]] || tpe <:< TypeRepr .of[immutable.ArraySeq [_]] ||
2898
- tpe.typeSymbol.fullName == " scala.IArray$package$.IArray" ||
2897
+ else if (tpe <:< TypeRepr .of[Array [_]] || tpe <:< TypeRepr .of[immutable.ArraySeq [_]] || isIArray(tpe) ||
2899
2898
tpe <:< TypeRepr .of[mutable.ArraySeq [_]]) withEncoderFor(methodKey, m, out) { (out, x) =>
2900
2899
val tpe1 = typeArg1(tpe)
2901
2900
tpe1.asType match
@@ -2926,7 +2925,7 @@ object JsonCodecMaker {
2926
2925
}
2927
2926
$out.writeArrayEnd()
2928
2927
}
2929
- } else if (tpe.typeSymbol.fullName == " scala.IArray$package$.IArray " ) {
2928
+ } else if (isIArray( tpe) ) {
2930
2929
val tx = x.asExprOf[IArray [t1]]
2931
2930
' {
2932
2931
$out.writeArrayStart()
0 commit comments