summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-09-26 23:49:03 +0000
committerPaul Phillips <paulp@improving.org>2011-09-26 23:49:03 +0000
commite412524fee20da975954c929893e88db17dbdd9a (patch)
treee7c491b8d303879b49426d98f714d81c672d885f /src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
parent660d80f682317eaf3d55a9b63bb95396ac417cdd (diff)
downloadscala-e412524fee20da975954c929893e88db17dbdd9a.tar.gz
scala-e412524fee20da975954c929893e88db17dbdd9a.tar.bz2
scala-e412524fee20da975954c929893e88db17dbdd9a.zip
ProductN, and method synthesis toolbox.
- Finished giving case classes a ProductN parent, and flipped it on. The "finish" part involved not breaking existing code where case classes manually extend the appropriate ProductN. (Like, Tuple 1-22.) - Generalized most of SyntheticMethods to ease method creation and class manipulation in general. - Fixed bugs related to the above, like the fact that this used to be a compile error: scala> case class Foo() extends Serializable <console>:28: error: trait Serializable is inherited twice case class Foo() extends Serializable ^ It feels like there's a better way to eliminate the duplicate parents, but after spending a lot of time chasing my tail in that peril-fraught zone between namer and typer, I don't see an easy path to improve on it. Closes SI-1799. For that modification to Typers, review by odersky.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Unapplies.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Unapplies.scala10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
index 67dd272d5a..4f7e6225e1 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
@@ -42,11 +42,11 @@ trait Unapplies extends ast.TreeDSL
tp.typeSymbol match { // unapplySeqResultToMethodSig
case BooleanClass => Nil
case OptionClass | SomeClass =>
- val prod = tp.typeArgs.head
- getProductArgs(prod) match {
- case Some(xs) if xs.size > 1 => xs // n > 1
- case _ => List(prod) // special n == 0 || n == 1
- }
+ val prod = tp.typeArgs.head
+ val targs = getProductArgs(prod)
+
+ if (targs.isEmpty || targs.tail.isEmpty) List(prod) // special n == 0 || n == 1
+ else targs // n > 1
case _ =>
throw new TypeError("result type "+tp+" of unapply not in {Boolean, Option[_], Some[_]}")
}