Skip to content

Commit 4d66d32

Browse files
authored
Merge pull request #7561 from dotty-staging/fix-#7516
Fix #7516: Don't insert `<unindent>` in front of `case`
2 parents 9c987cb + c64efd9 commit 4d66d32

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

compiler/src/dotty/tools/dotc/parsing/Scanners.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -555,9 +555,14 @@ object Scanners {
555555
token = INDENT
556556
end observeIndented
557557

558-
/** Insert an <outdent> token if next token closes an indentation region */
558+
/** Insert an <outdent> token if next token closes an indentation region.
559+
* Exception: continue if indentation region belongs to a `match` and next token is `case`.
560+
*/
559561
def observeOutdented(): Unit = currentRegion match
560-
case r: Indented if !r.isOutermost && closingRegionTokens.contains(token) =>
562+
case r: Indented
563+
if !r.isOutermost
564+
&& closingRegionTokens.contains(token)
565+
&& !(token == CASE && r.prefix == MATCH) =>
561566
currentRegion = r.enclosing
562567
insert(OUTDENT, offset)
563568
case _ =>

tests/pos/i7516.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
val foo: Int => Int = Some(7) match
2+
case Some(y) => x => y
3+
case None => identity[Int]

0 commit comments

Comments
 (0)