Skip to content

Scala 3 Derivation fails on evidence parameters #1369

@hearnadam

Description

@hearnadam

The following code compiles and produces Right(Box(42)) on Scala 2:

import zio.json._

case class Box[A: Numeric](value: A)

implicit def decoder[A: Numeric: JsonDecoder] = DeriveJsonDecoder.gen[Box[A]]

"""{"value": 42}""".fromJson[Box[Int]]
    No given instance of type scala.deriving.Mirror.Of[Playground.Box[A]] was found for parameter mirror of method gen in object DeriveJsonDecoder. Failed to synthesize an instance of type scala.deriving.Mirror.Of[Playground.Box[A]]:
    	* class Box is not a generic product because it takes more than one parameter list
    	* class Box is not a generic sum because it is not a sealed class

https://scastie.scala-lang.org/Pg8k649ETC6cOq7ybPRRow

This seems to be a limitation of using mirrors for Scala 3.

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