我试试
trait Foo[A] { def copy(int: Int): A } case class Bar(int: Int) extends Foo[Bar]
但我明白了
error: class Bar needs to be abstract,since method copy in trait Foo of type (int: Int)this.Bar is not defined
为什么Foo类不满足trait Bar定义的接口?
解决方法
我引用了
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.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。