aboutsummaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorFelix Mulder <felix.mulder@gmail.com>2017-02-14 17:12:45 +0100
committerGitHub <noreply@github.com>2017-02-14 17:12:45 +0100
commit38a385af56fa14e5b48b23f87bcf9ce7aa22a1ef (patch)
tree5c7d758346a5dc3053474609240d5354d8bec265 /compiler
parent4a8e05eeea2e378059c8f08b73062e39d8769b01 (diff)
parent6e23a94e4732ce1ab72c4af00f209a63a04b3813 (diff)
downloaddotty-38a385af56fa14e5b48b23f87bcf9ce7aa22a1ef.tar.gz
dotty-38a385af56fa14e5b48b23f87bcf9ce7aa22a1ef.tar.bz2
dotty-38a385af56fa14e5b48b23f87bcf9ce7aa22a1ef.zip
Merge pull request #1979 from dotty-staging/fix-#1975
Fix #1975: Align valdefs and for expressions for patterns
Diffstat (limited to 'compiler')
-rw-r--r--compiler/src/dotty/tools/dotc/ast/Desugar.scala12
1 files changed, 7 insertions, 5 deletions
diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala
index e3102fda2..deb239143 100644
--- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala
@@ -559,7 +559,7 @@ object desugar {
* ValDef or DefDef.
*/
def makePatDef(original: Tree, mods: Modifiers, pat: Tree, rhs: Tree)(implicit ctx: Context): Tree = pat match {
- case VarPattern(named, tpt) =>
+ case IdPattern(named, tpt) =>
derivedValDef(original, named, tpt, rhs, mods)
case _ =>
val rhsUnchecked = makeAnnotated("scala.unchecked", rhs)
@@ -816,7 +816,7 @@ object desugar {
* Otherwise this gives { case pat => body }
*/
def makeLambda(pat: Tree, body: Tree): Tree = pat match {
- case VarPattern(named, tpt) =>
+ case IdPattern(named, tpt) =>
Function(derivedValDef(pat, named, tpt, EmptyTree, Modifiers(Param)) :: Nil, body)
case _ =>
makeCaseLambda(CaseDef(pat, EmptyTree, body) :: Nil, unchecked = false)
@@ -898,7 +898,9 @@ object desugar {
}
def isIrrefutableGenFrom(gen: GenFrom): Boolean =
- gen.isInstanceOf[IrrefutableGenFrom] || isIrrefutable(gen.pat, gen.expr)
+ gen.isInstanceOf[IrrefutableGenFrom] ||
+ IdPattern.unapply(gen.pat).isDefined ||
+ isIrrefutable(gen.pat, gen.expr)
/** rhs.name with a pattern filter on rhs unless `pat` is irrefutable when
* matched against `rhs`.
@@ -1062,9 +1064,9 @@ object desugar {
TypeDef(tpnme.REFINE_CLASS, impl).withFlags(Trait)
}
- /** If tree is a variable pattern, return its name and type, otherwise return None.
+ /** If tree is of the form `id` or `id: T`, return its name and type, otherwise return None.
*/
- private object VarPattern {
+ private object IdPattern {
def unapply(tree: Tree)(implicit ctx: Context): Option[VarInfo] = tree match {
case id: Ident => Some(id, TypeTree())
case Typed(id: Ident, tpt) => Some((id, tpt))