Skip to content

Fix #7516: Don't insert <unindent> in front of case #7561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions compiler/src/dotty/tools/dotc/parsing/Scanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -555,9 +555,14 @@ object Scanners {
token = INDENT
end observeIndented

/** Insert an <outdent> token if next token closes an indentation region */
/** Insert an <outdent> token if next token closes an indentation region.
* Exception: continue if indentation region belongs to a `match` and next token is `case`.
*/
def observeOutdented(): Unit = currentRegion match
case r: Indented if !r.isOutermost && closingRegionTokens.contains(token) =>
case r: Indented
if !r.isOutermost
&& closingRegionTokens.contains(token)
&& !(token == CASE && r.prefix == MATCH) =>
currentRegion = r.enclosing
insert(OUTDENT, offset)
case _ =>
Expand Down
3 changes: 3 additions & 0 deletions tests/pos/i7516.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
val foo: Int => Int = Some(7) match
case Some(y) => x => y
case None => identity[Int]