zio-schema
zio-schema copied to clipboard
Schema derivation fails for enumeration with empty sub-tree
Schema derivation fails when intermediate types with no leaf case objects/classes derived from them are present in the sealed trait (or sealed abstract class) hierarchy.
I can understand failure to derive the schema if the whole hierarchy is empty (no leaf case class/object nodes at all), even though I think it should still work; but failing for the example below seems wrong:
//> using scala 3.4.0
//> using dep dev.zio::zio-schema:1.0.1
//> using dep dev.zio::zio-schema-derivation:1.0.1
sealed trait Thing
object Thing:
sealed trait Intermediate1 extends Thing
case object Object1 extends Intermediate1
sealed trait Intermediate2 extends Thing
// with the following line commented out: "Deriving schema for Thing is not supported"
// case object Object2 extends Intermediate2
given schema: zio.schema.Schema[Thing] = zio.schema.DeriveSchema.gen[Thing]
/bounty $75
💎 $75 bounty • ZIO
Steps to solve:
-
Start working: Comment
/attempt #667
with your implementation plan -
Submit work: Create a pull request including
/claim #667
in the PR body to claim the bounty - Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts
Thank you for contributing to zio/zio-schema!
/attempt #667
@varshith257: We appreciate your enthusiasm but since you already have 3 active bounty attempts, we're going to keep this open for other contributors to attempt. 🫡
@jdegoes I think this is not an easy fix. The issue seems for me to be, that our derivation depends on the Mirror
generated from the Scala 3 compiler. But in the case of a trait
as a leave, there is no Mirror
generated it seems. I think we don't need to rely on Mirror
, but that would mean a big refactoring
@987Nabil But it would be good if we move out relying on Mirror. It allows us lot flexibility. But yes, it gonna something big refactoring. Let's wait for @jdegoes thoughts on this