File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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+
918object 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}
You can’t perform that action at this time.
0 commit comments