diff options
Diffstat (limited to 'compiler/src/dotty/tools/dotc/parsing/Parsers.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index b46bc401d..c14108d2e 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -993,20 +993,22 @@ object Parsers { else { val saved = placeholderParams placeholderParams = Nil + + def wrapPlaceholders(t: Tree) = try + if (placeholderParams.isEmpty) t + else new WildcardFunction(placeholderParams.reverse, t) + finally placeholderParams = saved + val t = expr1(location) if (in.token == ARROW) { - placeholderParams = saved - closureRest(start, location, convertToParams(t)) + placeholderParams = Nil // don't interpret `_' to the left of `=>` as placeholder + wrapPlaceholders(closureRest(start, location, convertToParams(t))) } else if (isWildcard(t)) { placeholderParams = placeholderParams ::: saved t } - else - try - if (placeholderParams.isEmpty) t - else new WildcardFunction(placeholderParams.reverse, t) - finally placeholderParams = saved + else wrapPlaceholders(t) } } |