aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/ast/Desugar.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-11-17 12:36:58 +0100
committerMartin Odersky <odersky@gmail.com>2015-11-17 12:37:03 +0100
commite59c0baaff669d54eb502b2142783d9f5d75e3b5 (patch)
tree305d9d44ac4b23e968699d2998d8f2a185e617bf /src/dotty/tools/dotc/ast/Desugar.scala
parent6b061b5b94fb4e13a97274b28e0ab9ac78b69f27 (diff)
downloaddotty-e59c0baaff669d54eb502b2142783d9f5d75e3b5.tar.gz
dotty-e59c0baaff669d54eb502b2142783d9f5d75e3b5.tar.bz2
dotty-e59c0baaff669d54eb502b2142783d9f5d75e3b5.zip
More refined treatement of pattern type variables
Previously all lower case names were treated as variables in patterns. But that made code like x: cls crash the compiler if `cls` was a class. Also, it owuld preventing this idiom unless one wrote x: `cls` We now do it like scalac and treat lower case names as variables only in arguments of types.
Diffstat (limited to 'src/dotty/tools/dotc/ast/Desugar.scala')
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala
index 6c914c934..327b39897 100644
--- a/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/src/dotty/tools/dotc/ast/Desugar.scala
@@ -517,6 +517,12 @@ object desugar {
}
}
+ /** Expand variable identifier x to x @ _ */
+ def patternVar(tree: Tree)(implicit ctx: Context) = {
+ val Ident(name) = tree
+ Bind(name, Ident(nme.WILDCARD)).withPos(tree.pos)
+ }
+
def defTree(tree: Tree)(implicit ctx: Context): Tree = tree match {
case tree: ValDef => valDef(tree)
case tree: TypeDef => if (tree.isClassDef) classDef(tree) else typeDef(tree)