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

Macro support for tagged types in case classes

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4.1
    • Component/s: bson
    • Labels:
      None

      Description

      Hi!

      We've been using tagged types in our code base but unfortunately they are not supported in the current codec generator macro.
      Case classes having fields with tagged types are rejected by the Scala compiler simply because we cannot take `classOf` of a tagged type:

      scala> classOf[String with Tag]
      <console>:13: error: class type required but String with Tag found

      If it's acceptable as an enhancement, I'll be happy to submit a patch for this.

      Just for completeness, tagged types are something like this:

      trait Tag
      type EmailAddress = String with Tag
      val e: EmailAddress = "arbitrary string" // compilation error

      They introduce additional compile-time type information without changing the runtime representation of values.
      For more detailed introduction of tagged types please see e.g. here.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: