Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions tests/neg/i209.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

case class Foo(a: Int) {
private def copy(i: Int): Foo = Foo(2 * i)
}

object Test {
val foo = Foo(2)
foo.copy(3) // error
}
40 changes: 40 additions & 0 deletions tests/run/i209.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
case class Foo(a: Int) {
def copy(i: Int = 9): Foo = Foo(i)
}

case class Bar(a: Int, b: Int) {
def copy(i: Int = 4, j: Int = 6): Bar = Bar(i, j)
}

case class Baz(a: Int) {
def copy(i: Int): Baz = Baz(2 * i)
}

case class PBaz(a: Int) {
private def copy(i: Int): PBaz = PBaz(2 * i)
def copy2(i: Int): PBaz = copy(i)
}

object Test {
def main(args: Array[String]): Unit = {
val a = Foo(2)
assert(a == Foo(2))
assert(a.copy(5) == Foo(5))
assert(a.copy() == Foo(9))

val b = Bar(2, 3)
assert(b == Bar(2, 3))
assert(b.copy(5, 7) == Bar(5, 7))
assert(b.copy(5) == Bar(5, 6))
assert(b.copy(j = 5) == Bar(4, 5))
assert(b.copy() == Bar(4, 6))

val c = Baz(2)
assert(c == Baz(2))
assert(c.copy(3) == Baz(6))

val d = PBaz(2)
assert(d == PBaz(2))
assert(d.copy2(3) == PBaz(6))
}
}