summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2014-08-15 16:59:59 +1000
committerJason Zaugg <jzaugg@gmail.com>2014-08-15 17:05:24 +1000
commita16a635b647bb1cdb0759ab4ba1e794ec56d8081 (patch)
tree417fca794a17f4e759a315a28510a3ef0841cc43 /src
parent7a6947487dc8ea551ff7489b07cc30366b39d25e (diff)
downloadscala-a16a635b647bb1cdb0759ab4ba1e794ec56d8081.tar.gz
scala-a16a635b647bb1cdb0759ab4ba1e794ec56d8081.tar.bz2
scala-a16a635b647bb1cdb0759ab4ba1e794ec56d8081.zip
SI-8793 Fix patmat regression with extractors, existentials
In the same vein as SI-8128 / 3e9e2c65a, revert to the 2.10.x style of determining the types of the product elements of an extractor when using `TupleN`. I believe we can discard the special casing for Option/Tuple/Seq altogether with judicious application of `repackExistential` in `unapplyMethodTypes`. That ought to also fix fix SI-8149. But I'll target that work at 2.12.x.
Diffstat (limited to 'src')
-rw-r--r--src/reflect/scala/reflect/internal/Definitions.scala10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/reflect/scala/reflect/internal/Definitions.scala b/src/reflect/scala/reflect/internal/Definitions.scala
index bf560a21e5..02578e2038 100644
--- a/src/reflect/scala/reflect/internal/Definitions.scala
+++ b/src/reflect/scala/reflect/internal/Definitions.scala
@@ -836,12 +836,18 @@ trait Definitions extends api.StandardDefinitions {
def typeOfMemberNamedHead(tp: Type) = typeArgOfBaseTypeOr(tp, SeqClass)(resultOfMatchingMethod(tp, nme.head)())
def typeOfMemberNamedApply(tp: Type) = typeArgOfBaseTypeOr(tp, SeqClass)(resultOfMatchingMethod(tp, nme.apply)(IntTpe))
def typeOfMemberNamedDrop(tp: Type) = typeArgOfBaseTypeOr(tp, SeqClass)(resultOfMatchingMethod(tp, nme.drop)(IntTpe))
- def typesOfSelectors(tp: Type) = getterMemberTypes(tp, productSelectors(tp))
+ def typesOfSelectors(tp: Type) =
+ if (isTupleType(tp)) tp.typeArgs
+ else getterMemberTypes(tp, productSelectors(tp))
+
// SI-8128 Still using the type argument of the base type at Seq/Option if this is an old-style (2.10 compatible)
// extractor to limit exposure to regressions like the reported problem with existentials.
// TODO fix the existential problem in the general case, see test/pending/pos/t8128.scala
private def typeArgOfBaseTypeOr(tp: Type, baseClass: Symbol)(or: => Type): Type = (tp baseType baseClass).typeArgs match {
- case x :: Nil => x
+ case x :: Nil =>
+ val x1 = x
+ val x2 = repackExistential(x1)
+ x2
case _ => or
}