Skip to content

Commit

Permalink
fixed incorrect (but working) writer/reader generation for complex su…
Browse files Browse the repository at this point in the history
…m types
  • Loading branch information
Ковалев Георгий Алексеевич committed Oct 23, 2024
1 parent e1ddfc9 commit 0c971cc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ trait ConfigurationMacroUtils:
)
)

val discriminators: List[Term] = getAllChildren(tpe).map {
val discriminators: List[Term] = getAllChildren(tpe).distinct.map {
case tpe: TypeRef =>
Select(stub(tpe), symbol)
case tpe: TermRef =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private[derivation] class DerivationMacro(val quotes: Quotes)
): Expr[JsonObjectWriter[T]] =
val tpe = TypeRepr.of[T]
val parsedConfig = parseSumConfig[T]
val types = getAllChildren(tpe)
val types = getAllChildren(tpe).distinct
val (missingWriters, refs) = deriveMissingWritersForSum(types)
val mirror = '{ summonInline[Mirror.SumOf[T]] }
val writer = Block(
Expand Down Expand Up @@ -492,7 +492,7 @@ private[derivation] class DerivationMacro(val quotes: Quotes)
def deriveJsonReaderForSum[T: Type]: Expr[JsonReader[T]] =
val tpe = TypeRepr.of[T]
val parsed = parseSumConfig[T]
val children = getAllChildren(tpe)
val children = getAllChildren(tpe).distinct
parsed.discriminator match
case Some(DiscriminatorConfig(label, tpe, discriminators)) =>
tpe.asType match
Expand Down

0 comments on commit 0c971cc

Please sign in to comment.