summaryrefslogtreecommitdiff
path: root/src/reflect
diff options
context:
space:
mode:
authorJason Zaugg <jzaugg@gmail.com>2012-11-10 13:07:26 +0100
committerJason Zaugg <jzaugg@gmail.com>2012-11-10 13:13:14 +0100
commit8b2caf0746fd4405f2d47b54d17d484e6603c89d (patch)
tree452e657d03650d8760ab54ca05e0f277ea851259 /src/reflect
parent8b598436f64ca4e980c8a38f642085b4d23e2327 (diff)
downloadscala-8b2caf0746fd4405f2d47b54d17d484e6603c89d.tar.gz
scala-8b2caf0746fd4405f2d47b54d17d484e6603c89d.tar.bz2
scala-8b2caf0746fd4405f2d47b54d17d484e6603c89d.zip
SI-6646 Fix regression in for desugaring.
The early check in the parser of pattern irrefutability, added in c82ecab, failed to consider InitCaps and `backquoted` identifiers.
Diffstat (limited to 'src/reflect')
-rw-r--r--src/reflect/scala/reflect/internal/TreeInfo.scala45
1 files changed, 27 insertions, 18 deletions
diff --git a/src/reflect/scala/reflect/internal/TreeInfo.scala b/src/reflect/scala/reflect/internal/TreeInfo.scala
index 38e55a3c01..56a0bac72b 100644
--- a/src/reflect/scala/reflect/internal/TreeInfo.scala
+++ b/src/reflect/scala/reflect/internal/TreeInfo.scala
@@ -245,6 +245,33 @@ abstract class TreeInfo {
isSelfConstrCall(tree1) || isSuperConstrCall(tree1)
}
+ /** Is this tree comprised of nothing but identifiers,
+ * but possibly in bindings or tuples? For instance:
+ *
+ * {{{
+ * foo @ (bar, (baz, quux))
+ * }}}
+ *
+ * is a variable pattern; if the structure matches,
+ * then the remainder is inevitable.
+ *
+ * The following are not variable patterns.
+ *
+ * {{{
+ * foo @ (bar, (`baz`, Quux))
+ * foo @ (bar, Quux)
+ * }}}
+ */
+ def isVarPatternDeep(tree: Tree): Boolean = tree match {
+ case Bind(name, pat) => isVarPatternDeep(pat)
+ case Ident(name) => isVarPattern(tree)
+ case Apply(sel, args) =>
+ ( isReferenceToScalaMember(sel, TupleClass(args.size).name.toTermName)
+ && (args forall isVarPatternDeep)
+ )
+ case _ => false
+ }
+
/** Is tree a variable pattern? */
def isVarPattern(pat: Tree): Boolean = pat match {
case x: Ident => !x.isBackquoted && nme.isVariableName(x.name)
@@ -330,24 +357,6 @@ abstract class TreeInfo {
case _ => false
}
- /** Is this tree comprised of nothing but identifiers,
- * but possibly in bindings or tuples? For instance
- *
- * foo @ (bar, (baz, quux))
- *
- * is a variable pattern; if the structure matches,
- * then the remainder is inevitable.
- */
- def isVariablePattern(tree: Tree): Boolean = tree match {
- case Bind(name, pat) => isVariablePattern(pat)
- case Ident(name) => true
- case Apply(sel, args) =>
- ( isReferenceToScalaMember(sel, TupleClass(args.size).name.toTermName)
- && (args forall isVariablePattern)
- )
- case _ => false
- }
-
/** Is this argument node of the form <expr> : _* ?
*/
def isWildcardStarArg(tree: Tree): Boolean = tree match {