File tree Expand file tree Collapse file tree 4 files changed +39
-2
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 4 files changed +39
-2
lines changed Original file line number Diff line number Diff line change @@ -1139,7 +1139,11 @@ object Parsers {
11391139 lookahead.skipParens()
11401140 isArrowIndent()
11411141 else if lookahead.token == CASE && in.featureEnabled(Feature .relaxedLambdaSyntax) then
1142- Some (() => singleCaseMatch())
1142+ Some : () =>
1143+ inSepRegion(SingleLineLambda (_)):
1144+ singleCaseMatch()
1145+ .tap: _ =>
1146+ accept(ENDlambda )
11431147 else
11441148 None
11451149 isParamsAndArrow()
@@ -3230,6 +3234,9 @@ object Parsers {
32303234 val body = tok match
32313235 case ARROW => atSpan(in.skipToken()):
32323236 if exprOnly then
3237+ if in.token == ENDlambda then
3238+ in.token = NEWLINE
3239+ in.observeIndented()
32333240 if in.indentSyntax && in.isAfterLineEnd && in.token != INDENT then
32343241 warning(em """ Misleading indentation: this expression forms part of the preceding case.
32353242 |If this is intended, it should be indented for clarity.
Original file line number Diff line number Diff line change @@ -596,7 +596,7 @@ object Scanners {
596596 lastWidth = r.width
597597 newlineIsSeparating = lastWidth <= nextWidth || r.isOutermost
598598 indentPrefix = r.prefix
599- case _ : InString => ()
599+ case _ : InString | _ : SingleLineLambda => ()
600600 case r =>
601601 indentIsSignificant = indentSyntax
602602 r.proposeKnownWidth(nextWidth, lastToken)
Original file line number Diff line number Diff line change 1+ import scala .language .experimental .relaxedLambdaSyntax
2+
3+ @ main def Test =
4+ val list = List (1 , 2 , 3 )
5+
6+ val three = list
7+ .collect: case x =>
8+ (x, x + 1 )
9+ .toMap // error value toMap is not a member of (Int, Int)
10+
11+ val huh = list
12+ .collect: x => case y => (y, y + 1 ) // error expecting case at x
Original file line number Diff line number Diff line change 1+ import scala .language .experimental .relaxedLambdaSyntax
2+
3+ @ main def Test =
4+ val list = List (1 , 2 , 3 )
5+
6+ val three = list
7+ .collect: case x =>
8+ val y = x + 1
9+ (x, y)
10+ .toMap
11+
12+ val two = list
13+ .collect: x => (x, x + 1 )
14+ .toMap
15+
16+ val one = list
17+ .collect: case x => (x, x + 1 )
18+ .toMap
You can’t perform that action at this time.
0 commit comments