From aafc0fe172b8db946ccf74110d2f6fa257ffa094 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 21 Jul 2011 23:35:54 +0000 Subject: 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. --- test/files/pos/caseclass-productN.flags | 1 + test/files/pos/caseclass-productN.scala | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 test/files/pos/caseclass-productN.flags create mode 100644 test/files/pos/caseclass-productN.scala (limited to 'test/files') diff --git a/test/files/pos/caseclass-productN.flags b/test/files/pos/caseclass-productN.flags new file mode 100644 index 0000000000..e1b37447c9 --- /dev/null +++ b/test/files/pos/caseclass-productN.flags @@ -0,0 +1 @@ +-Xexperimental \ No newline at end of file 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 + } +} -- cgit v1.2.3