From 6eeb06facb4e0afca9b11b7859a929b31fc23f25 Mon Sep 17 00:00:00 2001 From: odersky Date: Wed, 22 Feb 2017 16:35:13 +0100 Subject: Fix #2009: Fix placeholder params logic for lambdas (#2019) * Fix #2009: Fix placeholder params logic for lambdas Logic was missing placeholders in rhs of lambdas. * Add comment * Fix typo --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'compiler/src/dotty/tools/dotc/parsing/Parsers.scala') 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) } } -- cgit v1.2.3