From dc2d928b262d8f3ce06cc112bdbbf526a905c5a0 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Thu, 10 Oct 2024 20:59:29 -0700 Subject: [PATCH] Split: make killOnFail an Option, set a default By default, set to true if exclude is empty. Also, require killOnFail in withOptionalToken and, in some cases, switch to using withSingleLine. --- .../org/scalafmt/internal/FormatOps.scala | 22 ++--- .../scala/org/scalafmt/internal/Router.scala | 95 ++++++++++--------- .../scala/org/scalafmt/internal/Split.scala | 50 ++++------ .../scala2/CommunityScala2Suite.scala | 36 +++---- .../scala3/CommunityScala3Suite.scala | 36 +++---- .../community/spark/CommunitySparkSuite.scala | 36 +++---- .../src/test/resources/default/Advanced.stat | 4 +- .../test/resources/default/Idempotency.stat | 2 +- .../src/test/resources/default/Lambda.stat | 2 +- .../test/resources/default/SearchState.stat | 2 +- .../src/test/resources/newlines/source.source | 2 +- .../resources/newlines/source_classic.stat | 8 +- .../test/resources/newlines/source_fold.stat | 32 ++++--- .../test/resources/newlines/source_keep.stat | 4 +- .../resources/newlines/source_unfold.stat | 38 +++++--- .../resources/rewrite/RedundantParens.stat | 4 +- .../test/resources/scala3/OptionalBraces.stat | 2 +- .../resources/scala3/OptionalBraces_fold.stat | 6 +- .../scala3/OptionalBraces_unfold.stat | 2 +- .../src/test/resources/scala3/Using.stat | 6 +- .../src/test/resources/scalajs/Apply.stat | 2 +- .../src/test/resources/scalajs/DefDef.stat | 4 +- .../test/scala/org/scalafmt/FormatTests.scala | 2 +- 23 files changed, 199 insertions(+), 198 deletions(-) diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala index 8390c89fd2..00d81cf691 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/FormatOps.scala @@ -762,8 +762,7 @@ class FormatOps( if (breakMany) TokenRanges.empty else insideBracesBlock(nextFT, expire, true) Split(ModExt(newStmtMod.getOrElse(spaceMod)), cost) - .withSingleLineNoOptimal(expire, exclude) - .withOptimalToken(expire, ignore = cost != 0) + .withSingleLine(expire, exclude, noOptimal = cost != 0) } } @@ -918,12 +917,10 @@ class FormatOps( else if (ft.hasBreak) Seq(nlSplit(0)) else { val slbEnd = getLastToken(x.superType) + val exclude = insideBlock[T.LeftParen](ft, slbEnd) Seq( - Split(Space, 0).withIndent(indent).withSingleLine( - slbEnd, - exclude = insideBlock[T.LeftParen](ft, slbEnd), - noSyntaxNL = true, - ), + Split(Space, 0).withIndent(indent) + .withSingleLine(slbEnd, exclude = exclude, noSyntaxNL = true), nlSplit(1), ) } @@ -998,7 +995,7 @@ class FormatOps( .orPolicy(pnlPolicy).withIndent(indent), Split(nlMod, 0).onlyIf(nlOnelineTag != Right(false)) .preActivateFor(nlOnelineTag.left.toOption) - .withSingleLine(lastToken, noSyntaxNL = noSyntaxNL) + .withSingleLineNoOptimal(lastToken, noSyntaxNL = noSyntaxNL) .withIndent(indent), Split(nlMod, 1).withPolicy(nlPolicy & pnlPolicy).withIndent(indent), ) @@ -1139,7 +1136,7 @@ class FormatOps( val afterLastParen = before(lastParen).right if (afterLastParen.is[T.Colon]) afterLastParen else lastParen } - val slbSplit = Split(space, 0).withSingleLine(slbEnd, killOnFail = true) + val slbSplit = Split(space, 0).withSingleLine(slbEnd) .preActivateFor(SplitTag.VerticalMultilineSingleLine) if (isBracket) { @@ -1500,8 +1497,11 @@ class FormatOps( exclude: TokenRanges = TokenRanges.empty, policy: Policy = Policy.NoPolicy, )(implicit fileLine: FileLine) = Split(Space, 0) - .withPolicy(policy | getSlb(end, exclude)) - .withOptimalToken(end, ignore = blast.start > end.start) + .withPolicy(policy | getSlb(end, exclude)).withOptimalToken( + end, + killOnFail = exclude.isEmpty, + ignore = blast.start > end.start, + ) def getSpaceSplit(penalty: Int, policy: Policy = Policy.NoPolicy)(implicit fileLine: FileLine, ) = { diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Router.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Router.scala index c54d4c017f..97a1aea193 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Router.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Router.scala @@ -399,18 +399,14 @@ class Router(formatOps: FormatOps) { } } // copy logic from `( ...`, binpack=never, defining `slbSplit` - val isBeforeOpenParen = style.newlines.isBeforeOpenParenCallSite - Split(NoSplit, 0).withSingleLine( - if (isBeforeOpenParen) closeFT.left - else endOfSingleLineBlock(closeFT), - noSyntaxNL = true, - killOnFail = true, - noOptimal = style.newlines.keep, - ).andPolicy(sldPolicy & noCloseSpacePolicy) + val slbEnd = + if (style.newlines.isBeforeOpenParenCallSite) close + else endOfSingleLineBlock(closeFT) + Split(NoSplit, 0).withSingleLine(slbEnd, noSyntaxNL = true) + .andPolicy(sldPolicy & noCloseSpacePolicy) } else Left { - Split(noSplitMod, 0) - .withSingleLine(expire, noSyntaxNL = true, killOnFail = true) + Split(noSplitMod, 0).withSingleLine(expire, noSyntaxNL = true) .andPolicy(sldPolicy) } } @@ -441,8 +437,8 @@ class Router(formatOps: FormatOps) { case _ => newlineBeforeClosingCurly & decideNewlinesOnlyAfterToken(arrowOptimal) } - Split(noSplitMod, 0).withSingleLine(arrowOptimal, killOnFail = true) - .andPolicy(policy).withIndent(lambdaIndent, close, Before) + Split(noSplitMod, 0).withSingleLine(arrowOptimal).andPolicy(policy) + .withIndent(lambdaIndent, close, Before) } val singleLineSplit = singleLineSplitOpt match { @@ -474,7 +470,7 @@ class Router(formatOps: FormatOps) { style.newlines.fold || !rightOwner.is[Defn] } => val exp = getOptimalTokenFor(getLastNonTrivial(leftFunc.body).left) - spaceSplitBase.withSingleLineNoOptimal(exp, noSyntaxNL = true) + spaceSplitBase.withSingleLine(exp, noSyntaxNL = true) case _ => Split.ignored } val (endIndent, expiresOn) = functionExpire(leftFunc) @@ -545,7 +541,10 @@ class Router(formatOps: FormatOps) { // if brace, don't add indent, the LeftBrace rule will do that Split(Space, 0) .withIndent(indent, endOfFunction, expiresOn, hasBlock) - .withOptimalToken(getOptimalTokenFor(next(nonComment))) + .withOptimalToken( + getOptimalTokenFor(next(nonComment)), + killOnFail = false, + ) Seq(noSplit, newlineSplit(1 + nestedApplies(leftOwner))) } @@ -861,7 +860,7 @@ class Router(formatOps: FormatOps) { )(newlinePolicy) } Split(noSplitMod, 0, policy = spacePolicy) - .withOptimalToken(lambdaToken) + .withOptimalToken(lambdaToken, killOnFail = true) } if (noSplitMod == null) Seq( @@ -1106,7 +1105,8 @@ class Router(formatOps: FormatOps) { ) getSlb else if (splitsForAssign.isDefined) singleLine(3) else singleLine(10) - val kof = style.newlines.keep && needDifferentFromOneArgPerLine + val kof = (style.newlines.keep || excludeBlocks.isEmpty) && + needDifferentFromOneArgPerLine val noOptimal = style.newlines.keep && !useOneArgPerLineSplit || singleArgument && !excludeBlocks.isEmpty && excludeBlocks.ranges.forall(_.lt.is[T.LeftParen]) @@ -1300,9 +1300,9 @@ class Router(formatOps: FormatOps) { else if (singleLineOnly || noNLPolicy == null) baseNoSplit .withSingleLine( close, - sjsExclude, + exclude = sjsExclude, noSyntaxNL = true, - killOnFail = !dangleCloseDelim, + killOnFail = Some(!dangleCloseDelim || sjsExclude.isEmpty), ) else { def noSingleArgIndents = oneline || singleArgAsInfix.isDefined || @@ -1451,7 +1451,10 @@ class Router(formatOps: FormatOps) { if style.newlines.avoidInResultType => val expire = getLastNonTrivialToken(returnType) val policy = PenalizeAllNewlines(expire, Constants.ShouldBeNewline) - Seq(Split(Space, 0).withPolicy(policy).withOptimalToken(expire)) + Seq( + Split(Space, 0).withPolicy(policy) + .withOptimalToken(expire, killOnFail = false), + ) case FormatToken(T.LeftParen(), T.LeftBrace(), _) => Seq(Split(NoSplit, 0)) @@ -1481,7 +1484,7 @@ class Router(formatOps: FormatOps) { val multiLine = decideNewlinesOnlyAfterToken(breakAfter) ==> decideNewlinesOnlyBeforeClose(close) Seq( - Split(Newline, 0).withSingleLine(close, killOnFail = true), + Split(Newline, 0).withSingleLine(close), Split(Space, 1, policy = multiLine), ) } @@ -1524,8 +1527,7 @@ class Router(formatOps: FormatOps) { val isBeforeOpenParen = style.newlines.isBeforeOpenParenCallSite val optimal: T = if (isBeforeOpenParen) rbft.left else endOfSingleLineBlock(rbft) - val noOptimal = style.newlines.keep - Split(NoSplit, 0).withSingleLine(optimal, noOptimal = noOptimal) + Split(NoSplit, 0).withSingleLine(optimal) } Seq(slbParensSplit.getOrElse(Split.ignored), Split(Space, 0)) @@ -1753,9 +1755,6 @@ class Router(formatOps: FormatOps) { val eft = if (nft.noBreak) nextNonCommentSameLineAfter(nft) else nft endOfSingleLineBlock(eft) } - def shouldKillOnFail() = - (style.binPack.callSite ne BinPack.Site.Never) && - isInfixArg(expireTree) val ftAfterRight = tokens(ft, 2) val baseSplits = style.newlines.getSelectChains match { @@ -1860,8 +1859,7 @@ class Router(formatOps: FormatOps) { case Newlines.unfold => val nlCost = if (nlOnly) 0 else 1 if (prevSelect.isEmpty && nextSelect.isEmpty) Seq( - Split(nlOnly, 0)(NoSplit) - .withSingleLine(getSlbEnd(), killOnFail = shouldKillOnFail()), + Split(nlOnly, 0)(NoSplit).withSingleLine(getSlbEnd()), Split(Newline, nlCost), ) else Seq( @@ -1882,7 +1880,7 @@ class Router(formatOps: FormatOps) { val end = nextSelect .fold(expire)(x => getLastNonTrivialToken(x.qual)) val exclude = insideBracesBlock(ft, end, parensToo = true) - Split(NoSplit, 0).withSingleLine(end, exclude) + Split(NoSplit, 0).withSingleLine(end, exclude = exclude) } Seq(noSplit, nlSplitBase) } else { @@ -2033,8 +2031,7 @@ class Router(formatOps: FormatOps) { if (style.danglingParentheses.ctrlSite) { val noSplit = if (style.align.openParenCtrlSite) Split(NoSplit, 0) - .withIndents(indents).withOptimalToken(close) - .withPolicy(penalizeNewlines) + .withIndents(indents).withPolicy(penalizeNewlines) .andPolicy(decideNewlinesOnlyBeforeCloseOnBreak(close)) else Split(NoSplit, 0).withSingleLine(close) Seq( @@ -2053,8 +2050,7 @@ class Router(formatOps: FormatOps) { val mod = if (isKeep && hasBreak()) Newline else Space(style.spaces.isSpaceAfterKeyword(right)) - val slb = Split(mod.isNL, 0)(mod) - .withSingleLine(expire, killOnFail = true) + val slb = Split(mod.isNL, 0)(mod).withSingleLine(expire) val mlSplitBase = Split(mod, if (slb.isIgnored) 0 else 1).withPolicy( if (isKeep) getBreakBeforeElsePolicy(owner) else getBreaksBeforeElseChainPolicy(owner), @@ -2141,8 +2137,10 @@ class Router(formatOps: FormatOps) { case FormatToken(_, _: T.KwThen | _: T.KwDo, _) => val okSpace = style.newlines.sourceIgnored || noBreak() Seq( - Split(!okSpace, 0)(Space) - .withOptimalToken(nextNonCommentSameLineAfter(ft).left), + Split(!okSpace, 0)(Space).withOptimalToken( + nextNonCommentSameLineAfter(ft).left, + killOnFail = false, + ), Split(Newline, 1), ) // Last else branch @@ -2231,8 +2229,8 @@ class Router(formatOps: FormatOps) { Seq( if (!singleLine) spaceSplit else spaceSplitWithoutPolicy.withSingleLine(close).andPolicy( - Policy ? !enclosed.exists(isInfixApp) || - getSingleLineInfixPolicy(close), + getSingleLineInfixPolicy(close), + ignore = !enclosed.exists(isInfixApp), ), newlineSplit(10, true), ) @@ -2310,9 +2308,10 @@ class Router(formatOps: FormatOps) { val onArrowPolicy = Policy.End == arrow ==> Policy.after(postArrow, "CASESLB>ARROW") { case Decision(_, ss) => ss.flatMap { s => - val nonSlbSplit = s.andPolicy(postArrowPolicy) - if (s.isNL) Seq(nonSlbSplit) - else Seq(s.withSingleLine(slbExpire, extend = true), nonSlbSplit) + Seq( + s.notIf(s.isNL).withSingleLine(slbExpire, extend = true), + s.andPolicy(postArrowPolicy), + ) } } Policy.RelayOnSplit((s, _) => s.isNL)(onArrowPolicy, postArrowPolicy) @@ -2379,7 +2378,7 @@ class Router(formatOps: FormatOps) { Seq(Split(Space, 0).withIndent(indent, noIndent)) } else Seq( // Either everything fits in one line or break on => - Split(Space, 0).withSingleLineNoOptimal(lastToken), + Split(Space, 0).withSingleLine(lastToken), Split(Newline, 1).withIndent(indent), ) @@ -2465,7 +2464,10 @@ class Router(formatOps: FormatOps) { case _: T.KwIf => end.left case x => x } - Seq(Split(Space, 0).withOptimalToken(opt), Split(Newline, 1)) + Seq( + Split(Space, 0).withOptimalToken(opt, killOnFail = false), + Split(Newline, 1), + ) } case FormatToken(_, T.Ident("|"), _) if rightOwner.is[Pat.Alternative] => val noNL = !style.newlines.keepBreak(newlines) @@ -2650,7 +2652,8 @@ class Router(formatOps: FormatOps) { Seq(Split(Space, 0).withIndents(spaceIndents)) else if (isRightCommentWithBreak(ft)) Seq(CtrlBodySplits.withIndent(Split(Space.orNL(ft), 0), body, endFt)) - else if (isJsNative(body)) Seq(Split(Space, 0).withSingleLine(endFt.left)) + else if (isJsNative(body)) + Seq(Split(Space, 0).withSingleLineNoOptimal(endFt.left)) else if ( style.dialect.allowSignificantIndentation && (style.newlines.sourceIgnored || ft.noBreak) && body.parent.exists { @@ -2732,7 +2735,7 @@ class Router(formatOps: FormatOps) { def baseSpaceSplit(implicit fileLine: FileLine) = Split(isRightCommentThenBreak(ft), 0)(Space) def twoBranches(implicit fileLine: FileLine) = baseSpaceSplit - .withOptimalToken(optimal).withPolicy { + .withOptimalToken(optimal, killOnFail = false).withPolicy { val exclude = insideBracesBlock(ft, expire) policyWithExclude(exclude, Policy.End.On, Policy.End.After)( PenalizeAllNewlines(expire, Constants.ShouldBeSingleLine), @@ -2745,7 +2748,8 @@ class Router(formatOps: FormatOps) { case _: Term.ForYield => twoBranches // we force newlines in try/catch/finally case _: Term.TryClause => Split.ignored - case _ => baseSpaceSplit.withOptimalToken(optimalWithComment) + case _ => baseSpaceSplit + .withOptimalToken(optimalWithComment, killOnFail = false) } Seq( spaceSplit, @@ -2771,7 +2775,8 @@ class Router(formatOps: FormatOps) { case t: Term.If => ifWithoutElse(t) case _ => true } - if (noSlb) Split(Space, 0).withOptimalToken(ft.right) + if (noSlb) Split(Space, 0) + .withOptimalToken(ft.right, killOnFail = false) else Split(Space, 0).withSingleLine(expire) } }(cost => CtrlBodySplits.withIndent(Split(Newline2x(ft), cost), endFt)) diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Split.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Split.scala index 8fceebb0f5..3aee33abf4 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Split.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/internal/Split.scala @@ -9,7 +9,7 @@ import scala.meta.tokens.Token case class OptimalToken( token: Token, - killOnFail: Boolean = false, + killOnFail: Boolean, recurseOnly: Boolean = false, ) { override def toString: String = { @@ -145,7 +145,7 @@ case class Split( def withOptimalTokenOpt( token: => Option[Token], - killOnFail: Boolean = false, + killOnFail: Boolean, extend: Boolean = false, recurseOnly: Boolean = false, ): Split = withOptimalAt( @@ -156,7 +156,7 @@ case class Split( def withOptimalToken( token: => Token, - killOnFail: Boolean = false, + killOnFail: Boolean, ignore: Boolean = false, extend: Boolean = false, recurseOnly: Boolean = false, @@ -198,10 +198,10 @@ case class Split( else throw new UnsupportedOperationException("Use orPolicy or andPolicy") def withSingleLine( - fexpire: => Token, + expire: => Token, exclude: => TokenRanges = TokenRanges.empty, noSyntaxNL: Boolean = false, - killOnFail: => Boolean = false, + killOnFail: => Option[Boolean] = None, rank: Int = 0, extend: Boolean = false, ignore: Boolean = false, @@ -210,39 +210,23 @@ case class Split( )(implicit fileLine: FileLine, style: ScalafmtConfig): Split = if (isIgnored || ignore) this else { - val expire = fexpire - withSingleLineAndOptimal( - expire, - expire, - exclude, + val expireEval = expire + val excludeEval = exclude + withOptimalToken( + expireEval, + killOnFail = killOnFail.getOrElse(excludeEval.isEmpty), + extend = extend, + ignore = noOptimal, + recurseOnly = recurseOnly, + ).withSingleLineNoOptimal( + expireEval, + excludeEval, noSyntaxNL, - killOnFail, rank, - extend, - noOptimal = noOptimal, - recurseOnly = recurseOnly, + extend = extend, ) } - def withSingleLineAndOptimal( - expire: => Token, - optimal: => Token, - exclude: => TokenRanges = TokenRanges.empty, - noSyntaxNL: Boolean = false, - killOnFail: Boolean = false, - rank: Int = 0, - extend: Boolean = false, - noOptimal: Boolean = false, - recurseOnly: Boolean = false, - )(implicit fileLine: FileLine, style: ScalafmtConfig): Split = - withOptimalToken( - optimal, - killOnFail, - extend = extend, - ignore = noOptimal, - recurseOnly = recurseOnly, - ).withSingleLineNoOptimal(expire, exclude, noSyntaxNL, rank, extend = extend) - def withSingleLineNoOptimal( expire: => Token, exclude: => TokenRanges = TokenRanges.empty, diff --git a/scalafmt-tests-community/scala2/src/test/scala/org/scalafmt/community/scala2/CommunityScala2Suite.scala b/scalafmt-tests-community/scala2/src/test/scala/org/scalafmt/community/scala2/CommunityScala2Suite.scala index 61e34b5895..6acd5db5f0 100644 --- a/scalafmt-tests-community/scala2/src/test/scala/org/scalafmt/community/scala2/CommunityScala2Suite.scala +++ b/scalafmt-tests-community/scala2/src/test/scala/org/scalafmt/community/scala2/CommunityScala2Suite.scala @@ -15,15 +15,15 @@ class CommunityScala2_12Suite extends CommunityScala2Suite("scala-2.12") { dialects.Scala212, 1277, statsPerStyle = Map( - "classic" -> TestStats.Style(expectedStatesVisited = 3805713), - "classicWithAlign" -> TestStats.Style(expectedStatesVisited = 3806692), - "classicWithRewrites" -> TestStats.Style(expectedStatesVisited = 3854699), - "fold" -> TestStats.Style(expectedStatesVisited = 6311579), - "keep" -> TestStats.Style(expectedStatesVisited = 3546688), - "keepWithAlign" -> TestStats.Style(expectedStatesVisited = 3546807), - "keepWithRewrites" -> TestStats.Style(expectedStatesVisited = 3595114), - "keepWithScalaJS" -> TestStats.Style(expectedStatesVisited = 4017088), - "unfold" -> TestStats.Style(expectedStatesVisited = 4538915), + "classic" -> TestStats.Style(expectedStatesVisited = 3742070), + "classicWithAlign" -> TestStats.Style(expectedStatesVisited = 3743075), + "classicWithRewrites" -> TestStats.Style(expectedStatesVisited = 3782691), + "fold" -> TestStats.Style(expectedStatesVisited = 5833337), + "keep" -> TestStats.Style(expectedStatesVisited = 3511074), + "keepWithAlign" -> TestStats.Style(expectedStatesVisited = 3511201), + "keepWithRewrites" -> TestStats.Style(expectedStatesVisited = 3557273), + "keepWithScalaJS" -> TestStats.Style(expectedStatesVisited = 3976667), + "unfold" -> TestStats.Style(expectedStatesVisited = 4192416), ), )) @@ -36,15 +36,15 @@ class CommunityScala2_13Suite extends CommunityScala2Suite("scala-2.13") { dialects.Scala213, 1287, statsPerStyle = Map( - "classic" -> TestStats.Style(expectedStatesVisited = 4724003), - "classicWithAlign" -> TestStats.Style(expectedStatesVisited = 4726470), - "classicWithRewrites" -> TestStats.Style(expectedStatesVisited = 4765754), - "fold" -> TestStats.Style(expectedStatesVisited = 8271306), - "keep" -> TestStats.Style(expectedStatesVisited = 4380943), - "keepWithAlign" -> TestStats.Style(expectedStatesVisited = 4381096), - "keepWithRewrites" -> TestStats.Style(expectedStatesVisited = 4428150), - "keepWithScalaJS" -> TestStats.Style(expectedStatesVisited = 4985371), - "unfold" -> TestStats.Style(expectedStatesVisited = 5556752), + "classic" -> TestStats.Style(expectedStatesVisited = 4633745), + "classicWithAlign" -> TestStats.Style(expectedStatesVisited = 4636185), + "classicWithRewrites" -> TestStats.Style(expectedStatesVisited = 4666467), + "fold" -> TestStats.Style(expectedStatesVisited = 7586090), + "keep" -> TestStats.Style(expectedStatesVisited = 4329252), + "keepWithAlign" -> TestStats.Style(expectedStatesVisited = 4329386), + "keepWithRewrites" -> TestStats.Style(expectedStatesVisited = 4373731), + "keepWithScalaJS" -> TestStats.Style(expectedStatesVisited = 4928298), + "unfold" -> TestStats.Style(expectedStatesVisited = 5125436), ), )) diff --git a/scalafmt-tests-community/scala3/src/test/scala/org/scalafmt/community/scala3/CommunityScala3Suite.scala b/scalafmt-tests-community/scala3/src/test/scala/org/scalafmt/community/scala3/CommunityScala3Suite.scala index 9261cfbfa2..0da21af414 100644 --- a/scalafmt-tests-community/scala3/src/test/scala/org/scalafmt/community/scala3/CommunityScala3Suite.scala +++ b/scalafmt-tests-community/scala3/src/test/scala/org/scalafmt/community/scala3/CommunityScala3Suite.scala @@ -15,15 +15,15 @@ class CommunityScala3_2Suite extends CommunityScala3Suite("scala-3.2") { dialects.Scala32, 791, statsPerStyle = Map( - "classic" -> TestStats.Style(expectedStatesVisited = 3651615), - "classicWithAlign" -> TestStats.Style(expectedStatesVisited = 3653930), - "classicWithRewrites" -> TestStats.Style(expectedStatesVisited = 3692216), - "fold" -> TestStats.Style(expectedStatesVisited = 6315060), - "keep" -> TestStats.Style(expectedStatesVisited = 3179974), - "keepWithAlign" -> TestStats.Style(expectedStatesVisited = 3180034), - "keepWithRewrites" -> TestStats.Style(expectedStatesVisited = 3109365), - "keepWithScalaJS" -> TestStats.Style(expectedStatesVisited = 3668368), - "unfold" -> TestStats.Style(expectedStatesVisited = 4251173), + "classic" -> TestStats.Style(expectedStatesVisited = 3550612), + "classicWithAlign" -> TestStats.Style(expectedStatesVisited = 3552306), + "classicWithRewrites" -> TestStats.Style(expectedStatesVisited = 3558246), + "fold" -> TestStats.Style(expectedStatesVisited = 5817619), + "keep" -> TestStats.Style(expectedStatesVisited = 3148692), + "keepWithAlign" -> TestStats.Style(expectedStatesVisited = 3148747), + "keepWithRewrites" -> TestStats.Style(expectedStatesVisited = 3079850), + "keepWithScalaJS" -> TestStats.Style(expectedStatesVisited = 3631800), + "unfold" -> TestStats.Style(expectedStatesVisited = 3882915), ), )) @@ -36,15 +36,15 @@ class CommunityScala3_3Suite extends CommunityScala3Suite("scala-3.3") { dialects.Scala33, 861, statsPerStyle = Map( - "classic" -> TestStats.Style(expectedStatesVisited = 3940695), - "classicWithAlign" -> TestStats.Style(expectedStatesVisited = 3942998), - "classicWithRewrites" -> TestStats.Style(expectedStatesVisited = 3983727), - "fold" -> TestStats.Style(expectedStatesVisited = 6856356), - "keep" -> TestStats.Style(expectedStatesVisited = 3420835), - "keepWithAlign" -> TestStats.Style(expectedStatesVisited = 3420899), - "keepWithRewrites" -> TestStats.Style(expectedStatesVisited = 3352827), - "keepWithScalaJS" -> TestStats.Style(expectedStatesVisited = 3945741), - "unfold" -> TestStats.Style(expectedStatesVisited = 4606935), + "classic" -> TestStats.Style(expectedStatesVisited = 3829673), + "classicWithAlign" -> TestStats.Style(expectedStatesVisited = 3831499), + "classicWithRewrites" -> TestStats.Style(expectedStatesVisited = 3839204), + "fold" -> TestStats.Style(expectedStatesVisited = 6310491), + "keep" -> TestStats.Style(expectedStatesVisited = 3388129), + "keepWithAlign" -> TestStats.Style(expectedStatesVisited = 3388188), + "keepWithRewrites" -> TestStats.Style(expectedStatesVisited = 3321872), + "keepWithScalaJS" -> TestStats.Style(expectedStatesVisited = 3907628), + "unfold" -> TestStats.Style(expectedStatesVisited = 4201569), ), )) diff --git a/scalafmt-tests-community/spark/src/test/scala/org/scalafmt/community/spark/CommunitySparkSuite.scala b/scalafmt-tests-community/spark/src/test/scala/org/scalafmt/community/spark/CommunitySparkSuite.scala index becb937d22..00e7ec02e5 100644 --- a/scalafmt-tests-community/spark/src/test/scala/org/scalafmt/community/spark/CommunitySparkSuite.scala +++ b/scalafmt-tests-community/spark/src/test/scala/org/scalafmt/community/spark/CommunitySparkSuite.scala @@ -15,15 +15,15 @@ class CommunitySpark3_4Suite extends CommunitySparkSuite("spark-3.4") { dialects.Scala213, 2585, statsPerStyle = Map( - "classic" -> TestStats.Style(expectedStatesVisited = 7904959), - "classicWithAlign" -> TestStats.Style(expectedStatesVisited = 7905199), - "classicWithRewrites" -> TestStats.Style(expectedStatesVisited = 7920730), - "fold" -> TestStats.Style(expectedStatesVisited = 13323293), - "keep" -> TestStats.Style(expectedStatesVisited = 6865865), - "keepWithAlign" -> TestStats.Style(expectedStatesVisited = 6865991), - "keepWithRewrites" -> TestStats.Style(expectedStatesVisited = 6885784), - "keepWithScalaJS" -> TestStats.Style(expectedStatesVisited = 7629048), - "unfold" -> TestStats.Style(expectedStatesVisited = 9725978), + "classic" -> TestStats.Style(expectedStatesVisited = 7822344), + "classicWithAlign" -> TestStats.Style(expectedStatesVisited = 7822643), + "classicWithRewrites" -> TestStats.Style(expectedStatesVisited = 7794473), + "fold" -> TestStats.Style(expectedStatesVisited = 12245923), + "keep" -> TestStats.Style(expectedStatesVisited = 6827133), + "keepWithAlign" -> TestStats.Style(expectedStatesVisited = 6827259), + "keepWithRewrites" -> TestStats.Style(expectedStatesVisited = 6841859), + "keepWithScalaJS" -> TestStats.Style(expectedStatesVisited = 7585082), + "unfold" -> TestStats.Style(expectedStatesVisited = 8655221), ), )) @@ -36,15 +36,15 @@ class CommunitySpark3_5Suite extends CommunitySparkSuite("spark-3.5") { dialects.Scala213, 2756, statsPerStyle = Map( - "classic" -> TestStats.Style(expectedStatesVisited = 8363446), - "classicWithAlign" -> TestStats.Style(expectedStatesVisited = 8363584), - "classicWithRewrites" -> TestStats.Style(expectedStatesVisited = 8386960), - "fold" -> TestStats.Style(expectedStatesVisited = 13972239), - "keep" -> TestStats.Style(expectedStatesVisited = 7258827), - "keepWithAlign" -> TestStats.Style(expectedStatesVisited = 7258849), - "keepWithRewrites" -> TestStats.Style(expectedStatesVisited = 7283864), - "keepWithScalaJS" -> TestStats.Style(expectedStatesVisited = 8102571), - "unfold" -> TestStats.Style(expectedStatesVisited = 10255444), + "classic" -> TestStats.Style(expectedStatesVisited = 8277862), + "classicWithAlign" -> TestStats.Style(expectedStatesVisited = 8278013), + "classicWithRewrites" -> TestStats.Style(expectedStatesVisited = 8254489), + "fold" -> TestStats.Style(expectedStatesVisited = 12884359), + "keep" -> TestStats.Style(expectedStatesVisited = 7218789), + "keepWithAlign" -> TestStats.Style(expectedStatesVisited = 7218811), + "keepWithRewrites" -> TestStats.Style(expectedStatesVisited = 7237620), + "keepWithScalaJS" -> TestStats.Style(expectedStatesVisited = 8057079), + "unfold" -> TestStats.Style(expectedStatesVisited = 9159697), ), )) diff --git a/scalafmt-tests/shared/src/test/resources/default/Advanced.stat b/scalafmt-tests/shared/src/test/resources/default/Advanced.stat index e7cecd5746..429e2404dc 100644 --- a/scalafmt-tests/shared/src/test/resources/default/Advanced.stat +++ b/scalafmt-tests/shared/src/test/resources/default/Advanced.stat @@ -206,7 +206,7 @@ options.testFilter match { }, { // else callStatement })(jstpe.AnyType) ->>> { stateVisits = 1740, stateVisits2 = 1728 } +>>> { stateVisits = 1724, stateVisits2 = 1712 } callStatement = js.If( genIsInstanceOf(callTrg, rtClass.tpe), { if (implMethodSym.owner == ObjectClass) { @@ -529,7 +529,7 @@ js.Function(List(objParam, depthParam), uri.getRawQuery(), uri.getRawFragment()).normalize() } ->>> { stateVisits = 1709 } +>>> { stateVisits = 1697, stateVisits2 = 1697 } if (uri.isAbsolute() || this.isOpaque()) uri else if ( uri._scheme.isEmpty && uri._authority.isEmpty && diff --git a/scalafmt-tests/shared/src/test/resources/default/Idempotency.stat b/scalafmt-tests/shared/src/test/resources/default/Idempotency.stat index 6b01d253d0..e2f49186d7 100644 --- a/scalafmt-tests/shared/src/test/resources/default/Idempotency.stat +++ b/scalafmt-tests/shared/src/test/resources/default/Idempotency.stat @@ -187,7 +187,7 @@ val bindingFuture = Http().bindAndHandleSync({ }) }} ->>> { stateVisits = 1944, stateVisits2 = 1943 } +>>> { stateVisits = 1900, stateVisits2 = 1899 } { { val core = BidiFlow.fromGraph(GraphDSL.create() { implicit b ⇒ diff --git a/scalafmt-tests/shared/src/test/resources/default/Lambda.stat b/scalafmt-tests/shared/src/test/resources/default/Lambda.stat index 48c9e78481..5a5ebad0a4 100644 --- a/scalafmt-tests/shared/src/test/resources/default/Lambda.stat +++ b/scalafmt-tests/shared/src/test/resources/default/Lambda.stat @@ -167,7 +167,7 @@ opt[File]("migrate2hocon") Some(AbsoluteFile.fromFile(file, c.common.workingDirectory)))) .text("""migrate .scalafmt CLI style configuration to hocon style configuration in .scalafmt.conf""") }} ->>> { stateVisits = 895, stateVisits2 = 894 } +>>> { stateVisits = 869, stateVisits2 = 868 } { { opt[File]("migrate2hocon") diff --git a/scalafmt-tests/shared/src/test/resources/default/SearchState.stat b/scalafmt-tests/shared/src/test/resources/default/SearchState.stat index 5bb57fd030..67c8b1dc43 100644 --- a/scalafmt-tests/shared/src/test/resources/default/SearchState.stat +++ b/scalafmt-tests/shared/src/test/resources/default/SearchState.stat @@ -465,7 +465,7 @@ EventsResponse.fromJson(json, run).success.value.events should be(Seq( ^.value := s.text), <.button("Add #", s.items.length + 1))) ).build ->>> { stateVisits = 972, stateVisits2 = 863 } +>>> { stateVisits = 842, stateVisits2 = 725 } val TodoApp = ReactComponentB[Unit]("TodoApp") .initialState(State(Nil, "")) .renderS(($, s) => diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source.source b/scalafmt-tests/shared/src/test/resources/newlines/source.source index 1d223a2d44..6a53dec282 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source.source +++ b/scalafmt-tests/shared/src/test/resources/newlines/source.source @@ -69,7 +69,7 @@ private[parser] trait CacheControlHeader { this: Parser with CommonRules with Co clearSB() ~ zeroOrMore(!'"' ~ !',' ~ qdtext ~ appendSB() | `quoted-pair`) ~ push(sb.toString) } } ->>> { stateVisits = 42976, stateVisits2 = 42976 } +>>> { stateVisits = 36399, stateVisits2 = 36399 } /** Copyright (C) 2009-2016 Lightbend Inc. */ diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat b/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat index f6209eb791..41aaf3b4bd 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat @@ -9920,7 +9920,7 @@ private object MemoMap { } } } ->>> { stateVisits = 305, stateVisits2 = 244 } +>>> { stateVisits = 296, stateVisits2 = 243 } private object MemoMap { def make(implicit trace: Trace @@ -10059,7 +10059,7 @@ object a { } } } ->>> { stateVisits = 1003, stateVisits2 = 899 } +>>> { stateVisits = 991, stateVisits2 = 887 } object a { private object MemoMap { def make(implicit trace: Trace): UIO[MemoMap] = @@ -10193,7 +10193,7 @@ object a { .map(_.filterNot(_.getCanonicalPath.contains("SSLOptions"))) } } ->>> { stateVisits = 1239, stateVisits2 = 699 } +>>> { stateVisits = 1222, stateVisits2 = 682 } object a { private def ignoreUndocumentedPackages( packages: Seq[Seq[File]] @@ -10333,7 +10333,7 @@ object a { .map(filterNot(getCanonicalPath.contains("SSLOptions"))) } } ->>> { stateVisits = 800, stateVisits2 = 556 } +>>> { stateVisits = 783, stateVisits2 = 539 } object a { private def ignoreUndocumentedPackages( packages: Seq[Seq[File]] diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat b/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat index c4005f4d64..ac06d2fa50 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat @@ -828,7 +828,7 @@ object a { })(result))))))) }).getMessage should ===("Ur state be b0rked") } ->>> { stateVisits = 652, stateVisits2 = 652 } +>>> { stateVisits = 623, stateVisits2 = 623 } object a { (intercept[java.lang.IllegalStateException] { wrap(result ⇒ @@ -7465,7 +7465,7 @@ class a { case _ => stepNoBreak(inner)(in) } } ->>> { stateVisits = 988, stateVisits2 = 988 } +>>> { stateVisits = 868, stateVisits2 = 868 } class a { def step( inner: Iteratee[E, A] @@ -8357,7 +8357,7 @@ object a { ) ) } ->>> { stateVisits = 78932 } +>>> { stateVisits = 6093, stateVisits2 = 6093 } object a { div(cls := "cover")( div(cls := "doc")(bodyContents), @@ -8388,7 +8388,8 @@ object a { h2(cls := "h200")( "Type parameters"), dl( - cls := "attributes attributes-small")( + cls := + "attributes attributes-small")( memberTypeParams *))).toSeq .flatten ++ Option.when( memberValueParams.nonEmpty)( @@ -8396,7 +8397,8 @@ object a { h2(cls := "h200")( "Value parameters"), dl( - cls := "attributes attributes-small")( + cls := + "attributes attributes-small")( memberValueParams *))) .toSeq.flatten :+ h2( cls := "h200")("Attributes") :+ dl( @@ -8442,7 +8444,7 @@ object a { ) ) } ->>> { stateVisits = 36381 } +>>> { stateVisits = 7564, stateVisits2 = 7564 } object a { div(cls := "cover")( div(cls := "doc")(bodyContents), @@ -8486,7 +8488,8 @@ object a { "Type parameters" ), dl( - cls := "attributes attributes-small" + cls := + "attributes attributes-small" )(memberTypeParams *) ) ).toSeq.flatten ++ Option.when( @@ -8497,7 +8500,8 @@ object a { "Value parameters" ), dl( - cls := "attributes attributes-small" + cls := + "attributes attributes-small" )(memberValueParams *) ) ).toSeq.flatten :+ h2( @@ -8775,7 +8779,7 @@ class UDFRegistration private[sql] (functionRegistry: FunctionRegistry) extends val inputEncoders: Seq[Option[ExpressionEncoder[_]]] = Try(ExpressionEncoder[A1]()).toOption :: Try(ExpressionEncoder[A2]()).toOption :: Try(ExpressionEncoder[A3]()).toOption :: Try(ExpressionEncoder[A4]()).toOption :: Try(ExpressionEncoder[A5]()).toOption :: Try(ExpressionEncoder[A6]()).toOption :: Try(ExpressionEncoder[A7]()).toOption :: Try(ExpressionEncoder[A8]()).toOption :: Try(ExpressionEncoder[A9]()).toOption :: Try(ExpressionEncoder[A10]()).toOption :: Try(ExpressionEncoder[A11]()).toOption :: Try(ExpressionEncoder[A12]()).toOption :: Try(ExpressionEncoder[A13]()).toOption :: Try(ExpressionEncoder[A14]()).toOption :: Try(ExpressionEncoder[A15]()).toOption :: Try(ExpressionEncoder[A16]()).toOption :: Try(ExpressionEncoder[A17]()).toOption :: Try(ExpressionEncoder[A18]()).toOption :: Try(ExpressionEncoder[A19]()).toOption :: Try(ExpressionEncoder[A20]()).toOption :: Try(ExpressionEncoder[A21]()).toOption :: Try(ExpressionEncoder[A22]()).toOption :: Nil } } ->>> { stateVisits = 807, stateVisits2 = 807 } +>>> { stateVisits = 732, stateVisits2 = 732 } class UDFRegistration private[sql] ( functionRegistry: FunctionRegistry ) extends Logging { @@ -9202,7 +9206,7 @@ object Build { }.evaluated, ) } ->>> { stateVisits = 1315, stateVisits2 = 1315 } +>>> { stateVisits = 1296, stateVisits2 = 1296 } object Build { lazy val scaladoc = project.in(file("scaladoc")) .settings(generateScalaDocumentation := Def.inputTaskDyn { @@ -9316,7 +9320,7 @@ private object MemoMap { } } } ->>> { stateVisits = 862, stateVisits2 = 862 } +>>> { stateVisits = 847, stateVisits2 = 847 } private object MemoMap { def make(implicit trace: Trace @@ -9450,7 +9454,7 @@ object a { } } } ->>> { stateVisits = 3808, stateVisits2 = 3808 } +>>> { stateVisits = 3538, stateVisits2 = 3538 } object a { private object MemoMap { def make(implicit trace: Trace): UIO[MemoMap] = Ref.Synchronized @@ -9567,7 +9571,7 @@ object a { .map(_.filterNot(_.getCanonicalPath.contains("SSLOptions"))) } } ->>> { stateVisits = 194795, stateVisits2 = 194795 } +>>> { stateVisits = 187773, stateVisits2 = 187773 } object a { private def ignoreUndocumentedPackages( packages: Seq[Seq[File]] @@ -9665,7 +9669,7 @@ object a { .map(filterNot(getCanonicalPath.contains("SSLOptions"))) } } ->>> { stateVisits = 12414, stateVisits2 = 12414 } +>>> { stateVisits = 12063, stateVisits2 = 12063 } object a { private def ignoreUndocumentedPackages( packages: Seq[Seq[File]] diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat b/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat index f147faa6a9..5d3ab510f3 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat @@ -9716,7 +9716,7 @@ private object MemoMap { } } } ->>> { stateVisits = 265, stateVisits2 = 215 } +>>> { stateVisits = 260, stateVisits2 = 215 } private object MemoMap { def make(implicit trace: Trace @@ -9851,7 +9851,7 @@ object a { } } } ->>> { stateVisits = 804, stateVisits2 = 702 } +>>> { stateVisits = 790, stateVisits2 = 702 } object a { private object MemoMap { def make(implicit trace: Trace): UIO[MemoMap] = diff --git a/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat b/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat index 2c0cb3bdae..a8ede0219b 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat @@ -8975,7 +8975,7 @@ object a { ) ) } ->>> { stateVisits = 2540 } +>>> { stateVisits = 684, stateVisits2 = 684 } object a { div(cls := "cover")( div(cls := "doc")(bodyContents), @@ -9016,7 +9016,8 @@ object a { h2(cls := "h200")( "Type parameters"), dl( - cls := "attributes attributes-small")( + cls := + "attributes attributes-small")( memberTypeParams *))) .toSeq .flatten ++ @@ -9028,14 +9029,16 @@ object a { h2(cls := "h200")( "Value parameters"), dl( - cls := "attributes attributes-small")( + cls := + "attributes attributes-small")( memberValueParams *))) .toSeq .flatten :+ h2(cls := "h200")( "Attributes") :+ dl( - cls := "attributes attributes-small")( + cls := + "attributes attributes-small")( attributes *))) } <<< #4133 binpack with complex nested applies and not forcing config style, dangling @@ -9076,7 +9079,7 @@ object a { ) ) } ->>> { stateVisits = 2346 } +>>> { stateVisits = 708, stateVisits2 = 708 } object a { div(cls := "cover")( div(cls := "doc")(bodyContents), @@ -9131,7 +9134,8 @@ object a { "Type parameters" ), dl( - cls := "attributes attributes-small" + cls := + "attributes attributes-small" )(memberTypeParams *) ) ) @@ -9146,7 +9150,8 @@ object a { "Value parameters" ), dl( - cls := "attributes attributes-small" + cls := + "attributes attributes-small" )(memberValueParams *) ) ) @@ -9156,7 +9161,8 @@ object a { "Attributes" ) :+ dl( - cls := "attributes attributes-small" + cls := + "attributes attributes-small" )(attributes *) ) ) @@ -9448,7 +9454,7 @@ class UDFRegistration private[sql] (functionRegistry: FunctionRegistry) extends val inputEncoders: Seq[Option[ExpressionEncoder[_]]] = Try(ExpressionEncoder[A1]()).toOption :: Try(ExpressionEncoder[A2]()).toOption :: Try(ExpressionEncoder[A3]()).toOption :: Try(ExpressionEncoder[A4]()).toOption :: Try(ExpressionEncoder[A5]()).toOption :: Try(ExpressionEncoder[A6]()).toOption :: Try(ExpressionEncoder[A7]()).toOption :: Try(ExpressionEncoder[A8]()).toOption :: Try(ExpressionEncoder[A9]()).toOption :: Try(ExpressionEncoder[A10]()).toOption :: Try(ExpressionEncoder[A11]()).toOption :: Try(ExpressionEncoder[A12]()).toOption :: Try(ExpressionEncoder[A13]()).toOption :: Try(ExpressionEncoder[A14]()).toOption :: Try(ExpressionEncoder[A15]()).toOption :: Try(ExpressionEncoder[A16]()).toOption :: Try(ExpressionEncoder[A17]()).toOption :: Try(ExpressionEncoder[A18]()).toOption :: Try(ExpressionEncoder[A19]()).toOption :: Try(ExpressionEncoder[A20]()).toOption :: Try(ExpressionEncoder[A21]()).toOption :: Try(ExpressionEncoder[A22]()).toOption :: Nil } } ->>> { stateVisits = 803, stateVisits2 = 803 } +>>> { stateVisits = 702, stateVisits2 = 702 } class UDFRegistration private[sql] ( functionRegistry: FunctionRegistry ) extends Logging { @@ -10012,7 +10018,7 @@ private object MemoMap { } } } ->>> { stateVisits = 369 } +>>> { stateVisits = 333, stateVisits2 = 333 } private object MemoMap { def make(implicit trace: Trace @@ -10157,7 +10163,7 @@ object a { } } } ->>> { stateVisits = 1049, stateVisits2 = 1049 } +>>> { stateVisits = 970, stateVisits2 = 970 } object a { private object MemoMap { def make(implicit trace: Trace): UIO[MemoMap] = Ref @@ -10301,7 +10307,7 @@ object a { .map(_.filterNot(_.getCanonicalPath.contains("SSLOptions"))) } } ->>> { stateVisits = 1237, stateVisits2 = 1237 } +>>> { stateVisits = 1168, stateVisits2 = 1168 } object a { private def ignoreUndocumentedPackages( packages: Seq[Seq[File]] @@ -10440,7 +10446,7 @@ object a { .map(filterNot(getCanonicalPath.contains("SSLOptions"))) } } ->>> { stateVisits = 791, stateVisits2 = 791 } +>>> { stateVisits = 739, stateVisits2 = 739 } object a { private def ignoreUndocumentedPackages( packages: Seq[Seq[File]] @@ -10541,8 +10547,10 @@ object a { object a { val expression = for ( - x <- loremipsumdolorsitametconsecteturadipiscingelitseddoeiusmodtemporincididu; - y <- loremipsumdolorsitametconsecteturadipiscingelitseddoeiusmodtemporincididu + x <- + loremipsumdolorsitametconsecteturadipiscingelitseddoeiusmodtemporincididu; + y <- + loremipsumdolorsitametconsecteturadipiscingelitseddoeiusmodtemporincididu ) yield x + y } diff --git a/scalafmt-tests/shared/src/test/resources/rewrite/RedundantParens.stat b/scalafmt-tests/shared/src/test/resources/rewrite/RedundantParens.stat index eee48be377..acb6937830 100644 --- a/scalafmt-tests/shared/src/test/resources/rewrite/RedundantParens.stat +++ b/scalafmt-tests/shared/src/test/resources/rewrite/RedundantParens.stat @@ -672,7 +672,7 @@ object Application { def main(args: Array[String]): Unit = app.run(args) } ->>> { stateVisits = 854, stateVisits2 = 854 } +>>> { stateVisits = 804, stateVisits2 = 804 } object Application { val app = reactiveWebApplication(a => a.beans(b => b.bean(classOf[SampleHandler]).bean(classOf[SampleService])) @@ -733,7 +733,7 @@ object Application { def main(args: Array[String]): Unit = app.run(args) } ->>> { stateVisits = 854, stateVisits2 = 854 } +>>> { stateVisits = 804, stateVisits2 = 804 } object Application { val app = reactiveWebApplication(a => a.beans(b => b.bean(classOf[SampleHandler]).bean(classOf[SampleService])) diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat index 4554686a2e..01c070e59c 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat @@ -6987,7 +6987,7 @@ object a { g.asInstanceOf[Tuple18[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18))).asInstanceOf[F] ) } ->>> { stateVisits = 2408, stateVisits2 = 2864 } +>>> { stateVisits = 1892, stateVisits2 = 1892 } object a { def tupledFunction18[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( untupledImpl = (g: G) => diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat index 8ba2ba00bf..139d0bdbe6 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat @@ -1005,7 +1005,7 @@ object Foo: case a: A if a.someField.otherField.function().exists(SomeObjectLongName.isTrue) => None ) ->>> { stateVisits = 917, stateVisits2 = 921 } +>>> { stateVisits = 790, stateVisits2 = 794 } object Foo: def bar = process( arg match @@ -5927,7 +5927,7 @@ object a: }) index } ->>> { stateVisits = 1565, stateVisits2 = 1565 } +>>> { stateVisits = 1513, stateVisits2 = 1513 } object a: private val packageIndex : scala.collection.Map[String, scala.collection.Seq[Path]] = { @@ -6696,7 +6696,7 @@ object a { g.asInstanceOf[Tuple18[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18))).asInstanceOf[F] ) } ->>> { stateVisits = 3402 } +>>> { stateVisits = 2441, stateVisits2 = 2441 } object a { def tupledFunction18[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( untupledImpl = (g: G) => diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat index 879cd32a07..f0324af816 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat @@ -7244,7 +7244,7 @@ object a { g.asInstanceOf[Tuple18[_, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _] => Any].apply((x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17, x18))).asInstanceOf[F] ) } ->>> { stateVisits = 941, stateVisits2 = 941 } +>>> { stateVisits = 627, stateVisits2 = 627 } object a { def tupledFunction18[F, G]: TupledFunction[F, G] = TupledFunction[F, G]( untupledImpl = diff --git a/scalafmt-tests/shared/src/test/resources/scala3/Using.stat b/scalafmt-tests/shared/src/test/resources/scala3/Using.stat index fe0d04ea98..0e08d1be56 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/Using.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/Using.stat @@ -55,9 +55,9 @@ maxColumn = 40 === def f(u: Universe)(using ctx: u.Context)(using s: ctx.Symbol, k: ctx.Kind, o: ctx.Other) = {} >>> -def f( - u: Universe -)(using ctx: u.Context)(using +def f(u: Universe)(using + ctx: u.Context +)(using s: ctx.Symbol, k: ctx.Kind, o: ctx.Other diff --git a/scalafmt-tests/shared/src/test/resources/scalajs/Apply.stat b/scalafmt-tests/shared/src/test/resources/scalajs/Apply.stat index babe067843..3afbf14624 100644 --- a/scalafmt-tests/shared/src/test/resources/scalajs/Apply.stat +++ b/scalafmt-tests/shared/src/test/resources/scalajs/Apply.stat @@ -600,7 +600,7 @@ optDef.getOrElse { bar, foo && bar, baz) ) } ->>> { stateVisits = 2153, stateVisits2 = 2105 } +>>> { stateVisits = 2133, stateVisits2 = 2101 } optDef.getOrElse { abort(foo && bar) diff --git a/scalafmt-tests/shared/src/test/resources/scalajs/DefDef.stat b/scalafmt-tests/shared/src/test/resources/scalajs/DefDef.stat index ed15d0c869..8439300a39 100644 --- a/scalafmt-tests/shared/src/test/resources/scalajs/DefDef.stat +++ b/scalafmt-tests/shared/src/test/resources/scalajs/DefDef.stat @@ -531,7 +531,7 @@ newlines.avoidForSimpleOverflow = [tooLong, punct, slc] object a { implicit def fromFunction17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R](f: scala.Function17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R]): js.Function17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R] = (x1: T1, x2: T2, x3: T3, x4: T4, x5: T5, x6: T6, x7: T7, x8: T8, x9: T9, x10: T10, x11: T11, x12: T12, x13: T13, x14: T14, x15: T15, x16: T16, x17: T17) => f(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x13, x14, x15, x16, x17) } ->>> { stateVisits = 1015, stateVisits2 = 472 } +>>> { stateVisits = 923, stateVisits2 = 472 } object a { implicit def fromFunction17[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, R]( @@ -788,7 +788,7 @@ val memberSel: Elems = )) ) )) ->>> { stateVisits = 1958, stateVisits2 = 1452 } +>>> { stateVisits = 1905, stateVisits2 = 1414 } val memberSel: Elems = if (valueMembers.forall(_.kind == "package")) NoElems else List( diff --git a/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala b/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala index 72b36f5fe5..ccc15b9a71 100644 --- a/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala +++ b/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala @@ -138,7 +138,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, 1777254, "total explored") + assertEquals(explored, 1493367, "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 :'(