From cb5daf3a5d9ab8195746e21801c3300d78efb52c Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Sat, 20 Feb 2016 22:51:12 -0800 Subject: SI-9665 Backquoted vbar in extractor pattern Allow an infix extractor named `|`, when backquoted. --- src/compiler/scala/tools/nsc/ast/parser/Parsers.scala | 4 ++-- test/files/pos/t9665.scala | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 test/files/pos/t9665.scala diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 831a0412cd..53cd2f6d59 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -1966,8 +1966,8 @@ self => case _ => EmptyTree } def loop(top: Tree): Tree = reducePatternStack(base, top) match { - case next if isIdentExcept(raw.BAR) => pushOpInfo(next) ; loop(simplePattern(badPattern3)) - case next => next + case next if isIdent && !isRawBar => pushOpInfo(next) ; loop(simplePattern(badPattern3)) + case next => next } checkWildStar orElse stripParens(loop(top)) } diff --git a/test/files/pos/t9665.scala b/test/files/pos/t9665.scala new file mode 100644 index 0000000000..1aa7a5d459 --- /dev/null +++ b/test/files/pos/t9665.scala @@ -0,0 +1,7 @@ + +object | { def unapply(x: (Any, Any)) = Some(x) } + +trait Test { + def f() = (1,2) match { case 1 `|` 2 => } + def g() = 2 match { case 1 | 2 => } +} -- cgit v1.2.3