In Scala 3, there exists a method fromProduct that gets automatically generated in case classes' companion objects. For backwards compatibility, this methods needs to be explicitly re-implemented and needs to accept tuples of all the necessary arities.
The generated should look something like this
def fromProduct(p: Product): Person = p.productArity match
case 2 =>
Person(
p.productElement(0).asInstanceOf[...],
p.productElement(1).asInstanceOf[...],
)
case 3 =>
Person(
p.productElement(0).asInstanceOf[...],
p.productElement(1).asInstanceOf[...],
p.productElement(2).asInstanceOf[...],
)
...
In Scala 3, there exists a method
fromProduct
that gets automatically generated in case classes' companion objects. For backwards compatibility, this methods needs to be explicitly re-implemented and needs to accept tuples of all the necessary arities.The generated should look something like this
Context:
/cc @armanbilge