summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-02-28 16:47:47 +0100
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-03-20 19:53:02 +0100
commit972bf59a65d98286697ca8eed6a80239259808e4 (patch)
tree7f85e85fc10db372045970cf1b0d8d3db7eafab3 /src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
parentd60099fb5543f92a81605873fea2d14637cbf4c6 (diff)
downloadscala-972bf59a65d98286697ca8eed6a80239259808e4.tar.gz
scala-972bf59a65d98286697ca8eed6a80239259808e4.tar.bz2
scala-972bf59a65d98286697ca8eed6a80239259808e4.zip
[vpm] TODO note: make unapply type list stricter
when an unapply returns Option[T] where T is some ProductN, does that mean the unapply returns 1 result, i.e., that T, or did it mean to return N results? to disambiguate, falling back to stricter spec-adherence, which requires T be exactly TupleN for N results for now, allow extractor result to be any product, not just tuple
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Unapplies.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Unapplies.scala5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
index cc272b7b8d..4f5b6868ae 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala
@@ -45,6 +45,11 @@ trait Unapplies extends ast.TreeDSL
case BooleanClass => Nil
case OptionClass | SomeClass =>
val prod = tp.typeArgs.head
+// the spec doesn't allow just any subtype of Product, it *must* be TupleN[...] -- see run/virtpatmat_extends_product.scala
+// this breaks plenty of stuff, though...
+// val targs =
+// if (isTupleType(prod)) getProductArgs(prod)
+// else List(prod)
val targs = getProductArgs(prod)
if (targs.isEmpty || targs.tail.isEmpty) List(prod) // special n == 0 || n == 1