Scala copy case class with generic type
问题 I have two classes PixelObject , ImageRefObject and some more, but here are just these two classes to simplify things. They all are subclasses of a trait Object that contains an uid. I need universal method which will copy a case class instance with a given new uid . The reason I need it because my task is to create a class ObjectRepository which will save instance of any subclass of Object and return it with new uid . My attempt: trait Object { val uid: Option[String] } trait UidBuilder[A <: