Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Case class extending trait not working with copy

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?

like image 350
Paul Draper Avatar asked May 18 '15 02:05

Paul Draper


1 Answers

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.

like image 102
ialekseev Avatar answered Sep 30 '22 05:09

ialekseev