play-json icon indicating copy to clipboard operation
play-json copied to clipboard

Json.writes[myScala3Enum] crashes play-json / the compilation?

Open nemoo opened this issue 1 year ago • 1 comments

Since somebody else had the same problem, I am now opening this ticket. I guess lots of users who are now starting to use scala 3 will run into this problem.

Expected behaviour If play-json currently does not support scala 3 enums via Json.writes, it should tell the user that in a compiler message.

Actual behaviour If Json.writes[T] is used on a scala 3 enum, compiling it with scala-cli or sbt crashes the compilation process. Compilation can only be killed via the task manager.

How to reproduce (tested on Java 11):

//> using scala 3.3.3
//> using dep org.playframework::play-json:3.0.2
import play.api.libs.json.*

enum Color:
  case red,green,blue

@main
def main =
  implicit val myWrites: OWrites[Color] = Json.writes[Color] //this line produces the crash

nemoo avatar Apr 29 '24 05:04 nemoo

Duplicate of #1017

cchantep avatar Jul 20 '24 15:07 cchantep