Uploaded image for project: 'Scala'
  1. Scala
  2. SCALA-343

Codec Macro support case object enum

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: 2.1.0
    • Fix Version/s: 2.4.0
    • Component/s: bson
    • Labels:
      None

      Description

      A common pattern in scala for enum is the following:

      sealed trait Greeting
      object Greeting {
        case object Hello   extends Greeting
        case object GoodBye extends Greeting
        case object Hi      extends Greeting
        case object Bye     extends Greeting
      }
      

      I found that first the Macro codec do not support decode/encode for this kind of enum pattern. And I have tried to write my own Codec[Greeting] but with no luck. Runtime error: cannot found codec for type Greeting$Hello$. It seems that no way I can write my own codec unless using marco. Can org.mongodb.scala.bson.codecs.Macros add support to this since this is a common enum pattern in Scala.

        Attachments

          Activity

            People

            • Votes:
              2 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: