softwaremill / diffx

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

Fix propagating child modifications throughout the DiffContext #423

Closed ghostbuster91 closed 2 years ago

ghostbuster91 commented 2 years ago

Relates to #418

This is a partial fix, because the design of DiffContext and how the modifications are propagated is fundamentally broken.

For example following case won't work:

    case class Address(house: Int, street: String)
    case class Person(name: String, address: Address)

    val add = Diff.summon[Address].ignore(_.house)
    val d = Diff
      .summon[Person]
      .modify(_.address)
      .setTo(add)
      .modify(_.address.street).ignore

The second modification won't work and there is no good way to fix it.