diffx
diffx copied to clipboard
Semi-auto derivation fails for reference to type with self-extension
The example below fails with the following error:
debug/Debug.scala:18: error: magnolia: could not find Diff.Typeclass for type Option[foobar.Debug.A]
in parameter 'id' of product type foobar.Debug.B
implicit val diffB: Derived[Diff[B]] = Diff.derived[B]
Versions:
- diffx: 0.4.5
- Magnolia: 0.17.0
- Mercator: 0.3.0
- Scala 2.13.5 but also reproduces on 2.12.13
package foobar
import com.softwaremill.diffx._
object Debug {
// This is scalapb.Message in real code.
trait T[C]
// Removing the inheritance makes it compile.
final case class A() extends T[A]
final case class B(id: Option[A])
implicit val diffA: Derived[Diff[A]] = Diff.derived[A]
implicit val diffB: Derived[Diff[B]] = Diff.derived[B]
// Fails with: error: magnolia: could not find Diff.Typeclass for type Option[foobar.Debug.Identifier]
}
The issue goes away when removing the extension of T but as mentioned in the comment this comes from generated ScalaPb code so this is not an option.
Hi,
Thanks for the report and sorry for the long delay. On the first glance it seems like the problem on the magnolia site.
I will try to confirm that in the upcoming week, but I doubt that it will be fixed shortly.