softwaremill / diffx

Pretty diffs for scala case classes
Apache License 2.0
342 stars 30 forks source link

Semi-auto derivation fails for reference to type with self-extension #237

Open cocreature opened 3 years ago

cocreature commented 3 years ago

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:

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.

ghostbuster91 commented 3 years ago

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.