Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema derivation fails for enumeration with empty sub-tree #667

Open
dubinsky opened this issue Mar 10, 2024 · 6 comments
Open

Schema derivation fails for enumeration with empty sub-tree #667

dubinsky opened this issue Mar 10, 2024 · 6 comments

Comments

@dubinsky
Copy link

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]
@jdegoes
Copy link
Member

jdegoes commented Jun 8, 2024

/bounty $75

Copy link

algora-pbc bot commented Jun 8, 2024

💎 $75 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #667 with your implementation plan
  2. Submit work: Create a pull request including /claim #667 in the PR body to claim the bounty
  3. 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!

Add a bountyShare on socials

@varshith257
Copy link

/attempt #667

Copy link

algora-pbc bot commented Jun 30, 2024

@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. 🫡

@987Nabil
Copy link
Contributor

@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

@varshith257
Copy link

varshith257 commented Jul 1, 2024

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants