Skip to content

Commit 1ebeec1

Browse files
committed
Code clean up
1 parent 92a9c03 commit 1ebeec1

File tree

1 file changed

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

1 file changed

+2
-10
lines changed

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

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,20 +2627,12 @@ object JsonCodecMaker {
26272627
if ($in.isNextToken('[')) ${readCreateBlock.asExprOf[T]}
26282628
else $in.readNullOrTokenError($default, '[')
26292629
}
2630-
} else if (isEnumOrModuleValue(tpe)) withDecoderFor(methodKey, default, in) { (in, default) =>
2630+
} else if (isEnumOrModuleValue(tpe) || tpe =:= TypeRepr.of[None.type]) withDecoderFor(methodKey, default, in) { (in, default) =>
26312631
'{
26322632
if ($in.isNextToken('{')) {
26332633
$in.rollbackToken()
26342634
$in.skip()
2635-
${Ref(tpe.termSymbol).asExprOf[T]}
2636-
} else $in.readNullOrTokenError($default, '{')
2637-
}
2638-
} else if (tpe =:= TypeRepr.of[None.type]) withDecoderFor(methodKey, default, in) { (in, default) =>
2639-
'{
2640-
if ($in.isNextToken('{')) {
2641-
$in.rollbackToken()
2642-
$in.skip()
2643-
${'{ None }.asExprOf[T]}
2635+
${if (tpe =:= TypeRepr.of[None.type]) '{ None }.asExprOf[T] else Ref(tpe.termSymbol).asExprOf[T]}
26442636
} else $in.readNullOrTokenError($default, '{')
26452637
}
26462638
} else if (isSealedClass(tpe)) withDecoderFor(methodKey, default, in) { (in, default) =>

0 commit comments

Comments
 (0)