Skip to content

Commit

Permalink
Merge pull request #325 from goshacodes/fix_complex_sum_types
Browse files Browse the repository at this point in the history
Fixed incorrect (but working) writer/reader generation for complex sum types
  • Loading branch information
dos65 authored Oct 23, 2024
2 parents 16c3f2f + aa560cb commit 0d95509
Showing 1 changed file with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -752,17 +752,19 @@ trait ConfigurationMacroUtils:
case '[t *: ts] => TypeRepr.of[t] :: typeReprsOf[ts]

def getAllChildren(tpe: TypeRepr): List[TypeRepr] =
tpe.asType match
case '[t] =>
Expr.summon[scala.deriving.Mirror.Of[t]] match
case Some('{
$m: scala.deriving.Mirror.SumOf[t] {
type MirroredElemTypes = subs
}
}) =>
typeReprsOf[subs].flatMap(getAllChildren)
case _ =>
List(tpe)
def loop(tpe: TypeRepr): List[TypeRepr] =
tpe.asType match
case '[t] =>
Expr.summon[scala.deriving.Mirror.Of[t]] match
case Some('{
$m: scala.deriving.Mirror.SumOf[t] {
type MirroredElemTypes = subs
}
}) =>
typeReprsOf[subs].flatMap(loop)
case _ =>
List(tpe)
loop(tpe).distinct

case class SelectedField(name: String, selector: Term)

Expand Down

0 comments on commit 0d95509

Please sign in to comment.