Scala: implementing method with return type of concrete instance
The only solution I could think of was this one: trait CanCopy[T <: CanCopy[T]] { self: T => type Self >: self.type <: T def copy(newId: Int): Self } abstract class A(id: Int) { self:CanCopy[_] => def copy(newId: Int): Self } The following would compile: class B(id: Int, x: String) extends A(id) with CanCopy[B] { … Read more