File tree Expand file tree Collapse file tree 4 files changed +12
-6
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 4 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -3232,6 +3232,9 @@ object Parsers {
32323232 val body = tok match
32333233 case ARROW => atSpan(in.skipToken()):
32343234 if exprOnly then
3235+ if in.token == ENDlambda then
3236+ in.token = NEWLINE
3237+ in.observeIndented()
32353238 if in.indentSyntax && in.isAfterLineEnd && in.token != INDENT then
32363239 warning(em """ Misleading indentation: this expression forms part of the preceding case.
32373240 |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 @@ -5,8 +5,8 @@ import scala.language.experimental.relaxedLambdaSyntax
55
66 val three = list
77 .collect: case x =>
8- (x, x + 1 ) // error not a member of tuple
9- .toMap
8+ (x, x + 1 )
9+ .toMap // error value toMap is not a member of (Int, Int)
1010
1111 val huh = list
1212 .collect: x => case y => (y, y + 1 ) // error expecting case at x
Original file line number Diff line number Diff line change @@ -3,13 +3,16 @@ import scala.language.experimental.relaxedLambdaSyntax
33@ main def Test =
44 val list = List (1 , 2 , 3 )
55
6+ val three = list
7+ .collect: case x =>
8+ val y = x + 1
9+ (x, y)
10+ .toMap
11+
612 val two = list
713 .collect: x => (x, x + 1 )
814 .toMap
915
1016 val one = list
1117 .collect: case x => (x, x + 1 )
1218 .toMap
13-
14- // val huh = list
15- // .collect: x => case y => (y, y + 1) correctly errors expecting case at x
You can’t perform that action at this time.
0 commit comments