Compiling using 2.10.0-M1 gives us:
if we change method foo to
the code compiles but throws CCE at runtime:
Ouch! If you compile it with -Xprint:cleanup you'll notice:
Which means pattern matching is completely confused about the arity (and thus types) of our case class.
Both definitions of foo this worked in 2.9.x so it's a regression. However, the whole idea of having private vals in case classes feels weird. We declare a member to be private but then we can access it through a pattern match (in 2.9.x). I think we should simply disallow private vals in case class's primary constructor. Proposed way to move forward:
1. bring back questionable semantics of 2.9.x back to master
2. Deprecate private vals in primary constructor of a case class
3. Disallow it in the next major release of Scala
PS. Yvirtpatmat fails to handle private vals properly as well.
PS2. The test-case has been extracted with blood and tears from specs2 by me and Nada Amin.