Skip to content

Scala 3: Add support for literal-based singleton types #1161

Description

@tarmath

Add support for SIP-23 - Literal-based singleton types

play-json 3.0.4
JDK 17

Reproducible Test Case

package play.api.libs.json

object TestSingletonTypes {
  case class CaseClassWithSingleton(
    singleton: "singleton"
  )  

  object CaseClassWithSingleton {
    implicit val format: Format[CaseClassWithSingleton] = Json.format[CaseClassWithSingleton]
  }
}

Result

Fails to compile with:

[error] -- Error: /Users/mpichette/src/git/oss/play-json/play-json/shared/src/test/scala-3/play/api/libs/json/TestSingletonTypes.scala:13:60 
[error] 13 |    implicit val format: Format[CaseClassWithSingleton] = Json.format[CaseClassWithSingleton]
[error]    |                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
[error]    |                    Instance not found: play.api.libs.json.Reads[String]

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions