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

Issues with Scala 3 enums derived from a trait #695

Open
OndrejSpanel opened this issue Mar 19, 2024 · 1 comment
Open

Issues with Scala 3 enums derived from a trait #695

OndrejSpanel opened this issue Mar 19, 2024 · 1 comment

Comments

@OndrejSpanel
Copy link
Contributor

Following code gives error with borer 1.14.0 and Scala 3.3.3:

package com.github.ondrejspanel.borer

import io.bullet.borer._
import io.bullet.borer.derivation.MapBasedCodecs._

sealed trait EBase
case class EE() extends EBase

enum E extends EBase:
  case A
  case B

object E:
  given codec: Codec[E] = deriveCodec

object EBase:
  given codec: Codec[EBase] = deriveAllCodecs

@main
def main(): Unit = {
  val c: EBase = EE()
  println(Json.encode(c).toUtf8String)
}

Error is:

value E is not a member of object com.github.ondrejspanel.borer.EBase
given codec: Codec[EBase] = deriveAllCodecs

When removing EE, a different error is shown:

Could not find any sub-types of EBase, likely because EBase is not a fully closed ADT.
Do you maybe have a sealed trait somewhere, which has no subclasses?

@sirthias
Copy link
Owner

Ok, interesting, thank you @OndrejSpanel !
I'll look into this ASAP.

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

No branches or pull requests

2 participants