Closed
Description
case class A(x: Int) {
def copy(x: Int = x) = A(x)
}
results in merge errors and friends:
-- Error: try/CaseClassCopyMergeError.scala:2:20 -------------------------------
2 | def copy(x: Int = this.x) = A(x)
| ^^^^^^
| cannot merge
| method copy: (x: Int): A and
| method copy: (x: Int): A;
| they are both defined in class A but have matching signatures
| (x: Int): A and
| (x: Int): A
| when seen as members of A(A.this)
-- Error: try/CaseClassCopyMergeError.scala:1:19 -------------------------------
1 |case class A(x: Int) {
| ^
| cannot merge
| method copy: (x: Int): A and
| method copy: (x: Int): A;
| they are both defined in class A but have matching signatures
| (x: Int): A and
| (x: Int): A
| when seen as members of A(A.this)
-- [E119] Duplicate Symbol Error: try/CaseClassCopyMergeError.scala:2:6 --------
2 | def copy(x: Int = this.x) = A(x)
| ^
|method copy in class A is already defined as def copy(x: Int): A at line 1.
|The definitions have matching type signatures after erasure.
-- Error: try/CaseClassCopyMergeError.scala:1:0 --------------------------------
1 |case class A(x: Int) {
|^
|two or more overloaded variants of method copy have default arguments
We have a use case for this in inox (where we override copy
to also also copy over some metadata), but I see how one would like to enforce some semantics for copy
on case classes. In any case, this should produce a more intelligible error message.
Metadata
Metadata
Assignees
Labels
No labels