diff options
author | Paul Phillips <paulp@improving.org> | 2011-07-21 23:35:54 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-07-21 23:35:54 +0000 |
commit | aafc0fe172b8db946ccf74110d2f6fa257ffa094 (patch) | |
tree | 6d2a5f3485a12beacfa5d1462218642463f55c7e /test/files/pos/caseclass-productN.scala | |
parent | ce895bbb40b26a64191c6be711643c50977072d6 (diff) | |
download | scala-aafc0fe172b8db946ccf74110d2f6fa257ffa094.tar.gz scala-aafc0fe172b8db946ccf74110d2f6fa257ffa094.tar.bz2 scala-aafc0fe172b8db946ccf74110d2f6fa257ffa094.zip |
As per discussion documented in SI-1799, brough...
As per discussion documented in SI-1799, brought back the ProductN
traits and synthesized them into case classes. It's -Xexperimental for
now because there may be minor implications for existing code which
should be discussed. And also because I snuck in another "improvement"
but it's probably too dangerous to be touching productIterator directly
and it should go into something else.
scala> case class Bippy(x: Int, y: Int)
defined class Bippy
scala> Bippy(5, 10).productIterator
res0: Iterator[Int] = non-empty iterator
^^^----- as opposed to Iterator[Any]
There is an even better idea available than lubbing the case class field
types: it starts with "H" and ends with "List"...
Review by oderksy.
Diffstat (limited to 'test/files/pos/caseclass-productN.scala')
-rw-r--r-- | test/files/pos/caseclass-productN.scala | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/files/pos/caseclass-productN.scala b/test/files/pos/caseclass-productN.scala new file mode 100644 index 0000000000..a0964218ac --- /dev/null +++ b/test/files/pos/caseclass-productN.scala @@ -0,0 +1,20 @@ +object Test { + class A + class B extends A + class C extends B + + case class Bippy[T](x: Int, y: List[T], z: T) { } + case class Bippy2[T](x: Int, y: List[T], z: T) { } + + def bippies = List( + Bippy(5, List(new C), new B), + Bippy2(5, List(new B), new C) + ) + + def bmethod(x: B) = () + + def main(args: Array[String]): Unit = { + bippies flatMap (_._2) foreach bmethod + bippies map (_._3) foreach bmethod + } +} |