@@ -334,11 +334,9 @@ class CirceProtocolGenerator private (circeVersion: CirceModelGenerator, applyVa
334
334
q " $acc ++ $field"
335
335
}
336
336
337
- Option (
338
- q """
337
+ q """
339
338
${circeVersion.encoderObjectCompanion}.instance[ ${Type .Name (clsName)}](a => _root_.io.circe.JsonObject.fromIterable( $allFields))
340
339
"""
341
- )
342
340
}
343
341
val (readOnlyDefn, readOnlyFilter) = NonEmptyList .fromList(readOnlyKeys).fold((List .empty[Stat ], identity[Term ] _)) { roKeys =>
344
342
(
@@ -347,7 +345,7 @@ class CirceProtocolGenerator private (circeVersion: CirceModelGenerator, applyVa
347
345
)
348
346
}
349
347
350
- Target .pure(encVal.map(encVal => q """
348
+ Target .pure(Option ( q """
351
349
implicit val ${suffixClsName(" encode" , clsName)}: ${circeVersion.encoderObject}[ ${Type .Name (clsName)}] = {
352
350
.. ${readOnlyDefn};
353
351
${readOnlyFilter(encVal)}
@@ -373,14 +371,12 @@ class CirceProtocolGenerator private (circeVersion: CirceModelGenerator, applyVa
373
371
decVal <-
374
372
if (paramCount == 0 ) {
375
373
Target .pure(
376
- Option [Term ](
377
- q """
374
+ q """
378
375
new _root_.io.circe.Decoder[ ${Type .Name (clsName)}] {
379
376
final def apply(c: _root_.io.circe.HCursor): _root_.io.circe.Decoder.Result[ ${Type .Name (clsName)}] =
380
377
_root_.scala.Right( ${Term .Name (clsName)}())
381
378
}
382
379
"""
383
- )
384
380
)
385
381
} else {
386
382
params.zipWithIndex
@@ -452,19 +448,17 @@ class CirceProtocolGenerator private (circeVersion: CirceModelGenerator, applyVa
452
448
}
453
449
.map { pairs =>
454
450
val (terms, enumerators) = pairs.unzip
455
- Option (
456
- q """
451
+ q """
457
452
new _root_.io.circe.Decoder[ ${Type .Name (clsName)}] {
458
453
final def apply(c: _root_.io.circe.HCursor): _root_.io.circe.Decoder.Result[ ${Type .Name (clsName)}] =
459
454
for {
460
455
.. ${enumerators}
461
456
} yield ${Term .Name (clsName)}(.. ${terms})
462
457
}
463
458
"""
464
- )
465
459
}
466
460
}
467
- } yield decVal.map(decVal => q """
461
+ } yield Option ( q """
468
462
implicit val ${suffixClsName(" decode" , clsName)}: _root_.io.circe.Decoder[ ${Type .Name (clsName)}] = $decVal
469
463
""" )
470
464
}
0 commit comments