From 48786d1e036068934facafef4a72cea61e1c4200 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 25 Sep 2019 10:28:18 +0200 Subject: [PATCH] Fix #7247: Align isVarPattern and patternVar --- compiler/src/dotty/tools/dotc/ast/Desugar.scala | 2 +- tests/neg/i7247.scala | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 tests/neg/i7247.scala diff --git a/compiler/src/dotty/tools/dotc/ast/Desugar.scala b/compiler/src/dotty/tools/dotc/ast/Desugar.scala index c9ace1ebd559..739694b709b8 100644 --- a/compiler/src/dotty/tools/dotc/ast/Desugar.scala +++ b/compiler/src/dotty/tools/dotc/ast/Desugar.scala @@ -1108,7 +1108,7 @@ object desugar { /** Expand variable identifier x to x @ _ */ def patternVar(tree: Tree)(implicit ctx: Context): Bind = { - val Ident(name) = tree + val Ident(name) = unsplice(tree) Bind(name, Ident(nme.WILDCARD)).withSpan(tree.span) } diff --git a/tests/neg/i7247.scala b/tests/neg/i7247.scala new file mode 100644 index 000000000000..9172f90fad07 --- /dev/null +++ b/tests/neg/i7247.scala @@ -0,0 +1,2 @@ +val x = "foo" match + case _: (a *: (b: Any)) => ??? // error \ No newline at end of file