Skip to content

Commit 9f68f86

Browse files
committed
Add more tests for #209
1 parent a34c90e commit 9f68f86

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

tests/neg/i209.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
case class Foo(a: Int) {
3+
private def copy(i: Int): Foo = Foo(2 * i)
4+
}
5+
6+
object Test {
7+
val foo = Foo(2)
8+
foo.copy(3) // error
9+
}

tests/run/i209.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ case class Bar(a: Int, b: Int) {
66
def copy(i: Int = 4, j: Int = 6): Bar = Bar(i, j)
77
}
88

9+
case class Baz(a: Int) {
10+
def copy(i: Int): Baz = Baz(2 * i)
11+
}
12+
13+
case class PBaz(a: Int) {
14+
private def copy(i: Int): PBaz = PBaz(2 * i)
15+
def copy2(i: Int): PBaz = copy(i)
16+
}
17+
918
object Test {
1019
def main(args: Array[String]): Unit = {
1120
val a = Foo(2)
@@ -19,5 +28,13 @@ object Test {
1928
assert(b.copy(5) == Bar(5, 6))
2029
assert(b.copy(j = 5) == Bar(4, 5))
2130
assert(b.copy() == Bar(4, 6))
31+
32+
val c = Baz(2)
33+
assert(c == Baz(2))
34+
assert(c.copy(3) == Baz(6))
35+
36+
val d = PBaz(2)
37+
assert(d == PBaz(2))
38+
assert(d.copy2(3) == PBaz(6))
2239
}
2340
}

0 commit comments

Comments
 (0)