japgolly / scalajs-react

Facebook's React on Scala.JS
https://japgolly.github.io/scalajs-react/
Apache License 2.0
1.64k stars 231 forks source link

Compilation fails in Scala 3 when deriving Reusability for case classes with multiple parameter groups #1075

Open rpiaggio opened 1 year ago

rpiaggio commented 1 year ago

Attempting to compile the following code in Scala 3

  final case class Foo(bar: Int)(val ctx: String)

  implicit val reuse: Reusability[Foo] = Reusability.derive

results in

[error] 108 |  implicit val reuse: Reusability[Foo] = Reusability.derive
[error]     |                                         ^^^^^^^^^^^^^^^^^^
[error]     | no implicit values were found that match type deriving.Mirror{
[error]     |   MirroredType = explore.targeteditor.ElevationPlotSemester.Foo; 
[error]     |     MirroredMonoType = explore.targeteditor.ElevationPlotSemester.Foo
[error]     |   ; MirroredElemTypes <: Tuple
[error]     | }

The expected behavior is that only the first parameter group is considered for reusability, as it does in Scala 2

matthughes commented 1 year ago

I think this is a Scala bug (if at all) not with this library. Compiling this with 3.2.0 we get a more helpful message:

[error] 43 |  implicit val reuse: Reusability[Foo] = Reusability.derive
[error]    |                                         ^^^^^^^^^^^^^^^^^^
[error]    |Failed to synthesize an instance of type deriving.Mirror{
[error]    |  MirroredType = Foo;
[error]    |    MirroredMonoType = Foo
[error]    |  ; MirroredElemTypes <: Tuple
[error]    |}:
[error]    |    * class Foo is not a generic product because it takes more than one parameter list
[error]    |    * class Foo is not a generic sum because it is not a sealed class
[error]    |----------------------------------------------------------------------------