Skip to content

Commit

Permalink
Splits: ensure break between yield and case
Browse files Browse the repository at this point in the history
  • Loading branch information
kitbellew committed Mar 4, 2025
1 parent 63ce63d commit 3f81083
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3381,6 +3381,12 @@ object SplitsAfterYield extends Splits {
case t: Term.ForYield => Some(t.body)
case _ => None
}).fold(Seq.empty[Split]) {
case b: Term.PartialFunction
if dialect.allowSignificantIndentation &&
nextNonComment(ft).right.is[T.KwCase] =>
val split = Split(Newline, 0)
.withIndent(cfg.indent.getSignificant, getLast(b), ExpiresOn.After)
Seq(split)
case b: Tree.Block
if right.is[T.LeftBrace] &&
matchingOptRight(ft).exists(_.idx >= getLast(b).idx) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8533,10 +8533,6 @@ for
yield
case Some(x) => foo
>>>
test does not parse: [dialect scala3] illegal start of simple expression
for foo <- Some(42)
yield case Some(x) => foo
^
====== full result: ======
for foo <- Some(42)
yield case Some(x) => foo
yield
case Some(x) => foo
Original file line number Diff line number Diff line change
Expand Up @@ -8196,8 +8196,6 @@ for
yield
case Some(x) => foo
>>>
test does not parse: [dialect scala3] illegal start of simple expression
for foo <- Some(42) yield case Some(x) => foo
^
====== full result: ======
for foo <- Some(42) yield case Some(x) => foo
for foo <- Some(42)
yield
case Some(x) => foo
Original file line number Diff line number Diff line change
Expand Up @@ -8555,12 +8555,7 @@ for
yield
case Some(x) => foo
>>>
test does not parse: [dialect scala3] illegal start of simple expression
for
foo <- Some(42)
yield case Some(x) => foo
^
====== full result: ======
for
foo <- Some(42)
yield case Some(x) => foo
yield
case Some(x) => foo
Original file line number Diff line number Diff line change
Expand Up @@ -8883,12 +8883,7 @@ for
yield
case Some(x) => foo
>>>
test does not parse: [dialect scala3] illegal start of simple expression
for foo <- Some(42)
yield case Some(x) =>
^
foo
====== full result: ======
for foo <- Some(42)
yield case Some(x) =>
foo
yield
case Some(x) =>
foo
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class FormatTests extends FunSuite with CanRunTests with FormatAssertions {
val explored = Debug.explored.get()
logger.debug(s"Total explored: $explored")
if (!onlyUnit && !onlyManual)
assertEquals(explored, 2536504, "total explored")
assertEquals(explored, 2536664, "total explored")
// TODO(olafur) don't block printing out test results.
TestPlatformCompat.executeAndWait(PlatformFileOps.writeFile(
FileOps.getPath("target", "index.html"),
Expand Down

0 comments on commit 3f81083

Please sign in to comment.