I try
trait Foo[A] {
def copy(int: Int): A
}
case class Bar(int: Int) extends Foo[Bar]
but I get
error: class Bar needs to be abstract, since method copy in trait Foo of type (int: Int)this.Bar is not defined
Since Bar
is a case class, it automatically defines a copy
method with exactly this signature.
Why doesn't the Foo
class satisfy the interface defined by the trait Bar
?
I am quoting the Scala's specification:
A method named copy is implicitly added to every case class unless the class already has a member (directly defined or inherited) with that name, or the class has a repeated parameter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With