Closed OndrejSpanel closed 2 months ago
Ok, interesting, thank you @OndrejSpanel ! I'll look into this ASAP.
I also just ran into the second error, ... is not a fully closed ADT
. Would love to see support for enum
s!
Ok, thank you, @mrdziuban ! The bug is confirmed but unfortunately not super easy to fix. Still, it needs to be corrected and will be done.
Note that Enum
s are supported already, the problem only arises of they extend another trait
or class
.
Thanks @sirthias, I realized why it wasn't working for me, my issue is unrelated to extending another trait
or class
. It looks like using Encoder.All.derived
or deriveAllEncoders
doesn't work when the enum
has only case object
members -- https://scastie.scala-lang.org/EB8BVPG0QMGkeqCSg2Pjlg
Is this intentional? I would like to use Encoder.All.derived
for all of my enum
s regardless of whether they're all case objects
or some case class
es are mixed in. sealed trait
s and sealed abstract class
es do not have the same issue.
@mrdziuban Ah, I see.
The case that an enum doesn't define any actual sub-classes (but only simple cases) is already supported, but the error message you are seeing isn't good. I've just pushed a fix for that.
In your case everything will work as expected with a simple derives Encoder
or deriveEncoder
call.
Background: Simple Enum cases do not actually define any new types or sub-classes. They simply designate instances of the enum type itself. Therefore a single Encoder
, Decoder
or Codec
is enough to support all cases and you don't need the deriveAll
macro at all.
I just published release 1.14.1 containing the full fill for this issue. Thank you again for reporting!
Following code gives error with borer 1.14.0 and Scala 3.3.3:
Error is:
When removing EE, a different error is shown: