here is a try with the idea of a factory (I did it before and gave up, but I will try it again well):
object Brickwall case class Brickwall[A](brick: A) trait Monoman { var wall: Ref[this.type, Brickwall[String]] def ref[V](v: V): Ref[this.type, V] } object Ref { implicit def unwrap[Repr](r: Ref[_, Repr]): Repr = r.repr implicit def wrap[A, Repr](repr: Repr): Ref[A, Repr] = new Impl[A, Repr](repr) private class Impl[A, Repr](val repr: Repr) extends Ref[A, Repr] } trait Ref[A, Repr] { def repr: Repr } def test(m: Monoman): Unit = { val w0 = m.wall val w1 = w0.copy(brick = "3.1415") m.wall = w1 // doesn't convert to Ref }
therefore, when the deployment is transparent, repacking does not work, and I suspect that it is impossible to make it work, again, because m.type never be output.
source share