You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There is inconsistent behaviour for EnumN derivation between Scala 2 and 3 when dealing with nested sealed trait hierarchies - also related to issue #668
In summary for the same Scala model:
when we compile in scala 2.13 we get only leaf nodes:
importzio.schema.Schemaimportzio.schema.DeriveSchemaobjectDeriveEnumSchemaBugextendsApp {
objectmodel {
sealedtraitInvoiceobjectInvoice {
finalcaseclassUnpaid(id: String) extendsInvoiceobjectUnpaid {
implicitvalschema:Schema.CaseClass1[String, Unpaid] =DeriveSchema.gen[Unpaid]
}
sealedtraitPaidextendsInvoiceobjectPaid {
finalcaseclassPaid1(id: String) extendsPaidobjectPaid1 {
implicitvalschema:Schema.CaseClass1[String, Paid1] =DeriveSchema.gen[Paid1]
}
finalcaseclassPaid2(id: String) extendsPaidobjectPaid2 {
implicitvalschema:Schema.CaseClass1[String, Paid2] =DeriveSchema.gen[Paid2]
}
implicitvalschema:Schema.Enum2[Paid1, Paid2, Paid] =DeriveSchema.gen[Paid]
}
/*when we compile in scala 2.13 we get this: implicit val schema: zio.schema.Schema.Enum3[ model.Invoice.Unpaid, model.Invoice.Paid.Paid1, model.Invoice.Paid.Paid2, model.Invoice ] = DeriveSchema.gen[Invoice]when we compile in scala 3.3.1 we get this - which I think is correct: implicit val schema: zio.schema.Schema.Enum2[ model.Invoice.Unpaid, model.Invoice.Paid, model.Invoice ] = DeriveSchema.gen[Invoice]*/// compiled in scala 2.13implicitvalschema: zio.schema.Schema.Enum3[
model.Invoice.Unpaid,
model.Invoice.Paid.Paid1, // the parent of this leaf node should be present, not the leaf node itself
model.Invoice.Paid.Paid2, // the parent of this leaf node should be present, not the leaf node itself
model.Invoice
] =DeriveSchema.gen[Invoice]
}
}
println(s"schema ${model.Invoice.schema}")
}
The text was updated successfully, but these errors were encountered:
googley42
changed the title
DeriveSchema macro - inconsistent behaviour for EnumN derivation between Scala 2 and 3
DeriveSchema macro - inconsistent behaviour for Enum N derivation between Scala 2 and 3
Oct 11, 2024
There is inconsistent behaviour for EnumN derivation between Scala 2 and 3 when dealing with nested sealed trait hierarchies - also related to issue #668
In summary for the same Scala model:
when we compile in scala 2.13 we get only leaf nodes:
when we compile in scala 3.3.1 we get only direct subclasses - which I think is correct:
Full reproducer below:
The text was updated successfully, but these errors were encountered: