summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-07-21 23:35:54 +0000
committerPaul Phillips <paulp@improving.org>2011-07-21 23:35:54 +0000
commitaafc0fe172b8db946ccf74110d2f6fa257ffa094 (patch)
tree6d2a5f3485a12beacfa5d1462218642463f55c7e /src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
parentce895bbb40b26a64191c6be711643c50977072d6 (diff)
downloadscala-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 'src/compiler/scala/tools/nsc/ast/parser/Parsers.scala')
-rw-r--r--src/compiler/scala/tools/nsc/ast/parser/Parsers.scala16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
index a90cb6c409..f0d6f4c5bf 100644
--- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
+++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala
@@ -2649,6 +2649,20 @@ self =>
* }}}
*/
def templateOpt(mods: Modifiers, name: Name, constrMods: Modifiers, vparamss: List[List[ValDef]], tstart: Int): Template = {
+ /** A synthetic ProductN parent for case classes. */
+ def extraCaseParents = (
+ if (settings.Xexperimental.value && mods.isCase) {
+ val arity = if (vparamss.isEmpty || vparamss.head.isEmpty) 0 else vparamss.head.size
+ if (arity == 0) Nil
+ else List(
+ AppliedTypeTree(
+ productConstrN(arity),
+ vparamss.head map (vd => vd.tpt)
+ )
+ )
+ }
+ else Nil
+ )
val (parents0, argss, self, body) = (
if (in.token == EXTENDS || in.token == SUBTYPE && mods.hasTraitFlag) {
in.nextToken()
@@ -2673,7 +2687,7 @@ self =>
else if (parents0.isEmpty) List(scalaAnyRefConstr)
else parents0
) ++ (
- if (mods.isCase) List(productConstr, serializableConstr)
+ if (mods.isCase) List(productConstr, serializableConstr) ++ extraCaseParents
else Nil
)