diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-09-26 17:10:39 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-09-27 10:04:17 +0200 |
commit | d290d0d1afe122fdeb3798364be7cda72cc182ec (patch) | |
tree | a49b12b40ffbcfe4a22df9adf2c5339a0af2757d /src | |
parent | bda48577d022811be58ce2b7f9e46890543ad45b (diff) | |
download | scala-d290d0d1afe122fdeb3798364be7cda72cc182ec.tar.gz scala-d290d0d1afe122fdeb3798364be7cda72cc182ec.tar.bz2 scala-d290d0d1afe122fdeb3798364be7cda72cc182ec.zip |
SI-7877 Only look for unapplies in term trees
Since Scala 2.10.2, the enclosed test case has crashed
in the backend. Before, we correctly rejected this pattern match.
My bisection landed at a merge commit f16f4ab157, although both
parents were good. So I don't quite trust that.
I do think the regression stems from the changes to allow:
case rx"AB(.+)" =>
Examples of this are in run/t7715.scala.
This commit limits the search for extractors to cases where the
function within the Apply is a term tree.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 3 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Unapplies.scala | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 157c6ba4de..37a6d50efc 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -3245,7 +3245,8 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper if (!tree.isErrorTyped) setError(tree) else tree // @H change to setError(treeCopy.Apply(tree, fun, args)) - case ExtractorType(unapply) if mode.inPatternMode => + // SI-7877 `isTerm` needed to exclude `class T[A] { def unapply(..) }; ... case T[X] =>` + case HasUnapply(unapply) if mode.inPatternMode && fun.isTerm => if (unapply == QuasiquoteClass_api_unapply) macroExpandUnapply(this, tree, fun, unapply, args, mode, pt) else doTypedUnapply(tree, fun0, fun, args, mode, pt) diff --git a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala index af19e3cf80..2411a23e7d 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Unapplies.scala @@ -39,7 +39,7 @@ trait Unapplies extends ast.TreeDSL { */ def unapplyMember(tp: Type): Symbol = directUnapplyMember(tp) filter (sym => !hasMultipleNonImplicitParamLists(sym)) - object ExtractorType { + object HasUnapply { def unapply(tp: Type): Option[Symbol] = unapplyMember(tp).toOption } |