Skip to content
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

Router: force NL after ; in optional-brace block #4510

Merged
merged 2 commits into from
Nov 5, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class FormatTokens(leftTok2tok: Map[TokenHash, Int])(val arr: Array[FormatToken]
getDelimsIfEnclosed(tree).map(_._2)

def isEnclosedInMatching(tokens: Tokens, tree: Tree): Boolean =
getHeadIfEnclosed(tokens, tree).isDefined
getDelimsIfEnclosed(tokens, tree).isDefined
def isEnclosedInMatching(tree: Tree): Boolean =
isEnclosedInMatching(tree.tokens, tree)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,8 +666,14 @@ class Router(formatOps: FormatOps) {
// New statement
case FormatToken(_: T.Semicolon, _, StartsStatementRight(stmt))
if !stmt.is[Term.EndMarker] =>
val noSpace = !style.newlines.okSpaceForSource(newlines) ||
style.dialect.allowSignificantIndentation &&
stmt.is[Case] && stmt.parent.forall {
case p: Tree.Block => !isEnclosedInMatching(p)
case _ => false
}
Seq(
Split(!style.newlines.okSpaceForSource(newlines), 0)(Space)
Split(noSpace, 0)(Space)
.withSingleLine(endOfSingleLineBlock(getLast(stmt))),
// For some reason, this newline cannot cost 1.
Split(Newline2x(ft), 0),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ abstract class CommunityScala3Suite(name: String)

class CommunityScala3_2Suite extends CommunityScala3Suite("scala-3.2") {

override protected def totalStatesVisited: Option[Int] = Some(32288017)
override protected def totalStatesVisited: Option[Int] = Some(32288009)

override protected def builds = Seq(getBuild("3.2.2", dialects.Scala32, 791))

}

class CommunityScala3_3Suite extends CommunityScala3Suite("scala-3.3") {

override protected def totalStatesVisited: Option[Int] = Some(34858906)
override protected def totalStatesVisited: Option[Int] = Some(34858898)

override protected def builds = Seq(getBuild("3.3.3", dialects.Scala33, 861))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7519,3 +7519,13 @@ val bar: Int => Pf =
>>>
val bar: Int => Pf =
case msg: Int => msg + 1
<<< #4133 braceless in `match` with a semicolon between cases
tag match
case TYPEREFsymbol | TYPEREFdirect | TERMREFsymbol | TERMREFdirect =>
node.refPrivate = in0.readByte() == PRIVATE;
case _ =>
>>>
tag match
case TYPEREFsymbol | TYPEREFdirect | TERMREFsymbol | TERMREFdirect =>
node.refPrivate = in0.readByte() == PRIVATE;
case _ =>
Original file line number Diff line number Diff line change
Expand Up @@ -7233,3 +7233,13 @@ val bar: Int => Pf =
>>>
val bar: Int => Pf =
case msg: Int => msg + 1
<<< #4133 braceless in `match` with a semicolon between cases
tag match
case TYPEREFsymbol | TYPEREFdirect | TERMREFsymbol | TERMREFdirect =>
node.refPrivate = in0.readByte() == PRIVATE;
case _ =>
>>>
tag match
case TYPEREFsymbol | TYPEREFdirect | TERMREFsymbol | TERMREFdirect =>
node.refPrivate = in0.readByte() == PRIVATE;
case _ =>
Original file line number Diff line number Diff line change
Expand Up @@ -7548,3 +7548,13 @@ val bar: Int => Pf =
>>>
val bar: Int => Pf =
case msg: Int => msg + 1
<<< #4133 braceless in `match` with a semicolon between cases
tag match
case TYPEREFsymbol | TYPEREFdirect | TERMREFsymbol | TERMREFdirect =>
node.refPrivate = in0.readByte() == PRIVATE;
case _ =>
>>>
tag match
case TYPEREFsymbol | TYPEREFdirect | TERMREFsymbol | TERMREFdirect =>
node.refPrivate = in0.readByte() == PRIVATE;
case _ =>
Original file line number Diff line number Diff line change
Expand Up @@ -7828,3 +7828,13 @@ val bar: Int => Pf =
val bar: Int => Pf =
case msg: Int =>
msg + 1
<<< #4133 braceless `match` with a semicolon between cases
tag match
case TYPEREFsymbol | TYPEREFdirect | TERMREFsymbol | TERMREFdirect =>
node.refPrivate = in0.readByte() == PRIVATE;
case _ =>
>>>
tag match
case TYPEREFsymbol | TYPEREFdirect | TERMREFsymbol | TERMREFdirect =>
node.refPrivate = in0.readByte() == PRIVATE;
case _ =>
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,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, 1497775, "total explored")
assertEquals(explored, 1498031, "total explored")
val results = debugResults.result()
// TODO(olafur) don't block printing out test results.
// I don't want to deal with scalaz's Tasks :'(
Expand Down
Loading