From b87d1752863a9b1bce2e2a04d5ea1efc8de40fbf Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Tue, 31 Dec 2024 11:46:28 -0800 Subject: [PATCH] Newlines: add `{type,pat}Site` to `infix` With one already present for Term.ApplyInfix, let's add additional ones for Type.ApplyInfix and Pat.ExtractInfix. --- docs/configuration.md | 6 ++++ .../scala/org/scalafmt/config/Newlines.scala | 29 +++++++++------- .../scala/org/scalafmt/internal/Router.scala | 2 +- .../scala/org/scalafmt/util/TreeOps.scala | 13 ++++++-- .../scala2/CommunityScala2Suite.scala | 4 +-- .../scala3/CommunityScala3Suite.scala | 4 +-- .../resources/newlines/source_classic.stat | 33 +++++++++---------- .../test/resources/newlines/source_fold.stat | 23 +++++++------ .../test/resources/newlines/source_keep.stat | 32 +++++++++--------- .../resources/newlines/source_unfold.stat | 16 +++++---- .../test/resources/scala3/OptionalBraces.stat | 2 ++ .../resources/scala3/OptionalBraces_fold.stat | 2 ++ .../resources/scala3/OptionalBraces_keep.stat | 8 +++-- .../scala3/OptionalBraces_unfold.stat | 2 ++ .../test/scala/org/scalafmt/FormatTests.scala | 2 +- 15 files changed, 103 insertions(+), 75 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index c0524abb3..9a92f6e00 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -2433,6 +2433,12 @@ expressions. It contains the following parameter groups: - `termSite` - primarily applies to ordinary infix expressions (`Term.ApplyInfix`) +- `typeSite`: + - applies to infix expressions within types (`Type.ApplyInfix`) only + - defaults to `termSite` if _no fields_ are specified +- `patSite`: + - applies to infix expressions within patterns (`Pat.ExtractInfix`) only + - defaults to `termSite` if _no fields_ are specified Each of these groups has several parameters of its own (replacing deprecated `newlines.afterInfixXxx`, originally added in v2.5.0, which moved to `termSite`): diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/config/Newlines.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/config/Newlines.scala index 6343428c8..6ab73b51e 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/config/Newlines.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/config/Newlines.scala @@ -245,9 +245,9 @@ case class Newlines( @inline def keepBreak(implicit ft: FT): Boolean = keepBreak(ft.hasBreak) - def checkInfixConfig(termCnt: Int)(implicit - cfg: ScalafmtConfig, // TODO: add typeSite, patSite - ): Newlines = copy(infix = infix.checkInfixCounts(termCnt)) + def checkInfixConfig(termCnt: Int, typeCnt: Int, patCnt: Int)(implicit + cfg: ScalafmtConfig, + ): Newlines = copy(infix = infix.checkInfixCounts(termCnt, typeCnt, patCnt)) lazy val forceBeforeImplicitParamListModifier: Boolean = implicitParamListModifierForce.contains(before) @@ -382,22 +382,27 @@ object Newlines { case class Infix( private val termSite: Infix.Site = Infix.Site.default, - // TODO: add typeSite and patSite + private val typeSite: Option[Infix.Site] = None, + private val patSite: Option[Infix.Site] = None, ) { - def checkInfixCounts(termCnt: Int)(implicit - cfg: ScalafmtConfig, // TODO: add typeSite, patSite + def checkInfixCounts(termCnt: Int, typeInfix: Int, patInfix: Int)(implicit + cfg: ScalafmtConfig, ): Infix = copy( - // TODO: add typeSite, patSite termSite = termSite.checkConfig(termCnt)(None), + typeSite = Some(typeSite.getOrElse(termSite).checkConfig(typeInfix) { + val useSome = !cfg.newlines.keep && cfg.dialect.useInfixTypePrecedence + if (useSome) Some(Infix.some) else None + }), + patSite = Some(patSite.getOrElse(termSite).checkConfig(patInfix)(None)), ) - def get(tree: Tree)(implicit cfg: ScalafmtConfig) = { - val useSome = (termSite.style eq null) && !cfg.newlines.keep && - tree.is[Type] && cfg.dialect.useInfixTypePrecedence - if (useSome) termSite.copy(style = Infix.some) else termSite + def get(tree: Tree): Infix.Site = tree match { + case _: Type => typeSite.getOrElse(termSite) + case _: Pat => patSite.getOrElse(termSite) + case _ => termSite } - def keep(tree: Tree)(implicit cfg: ScalafmtConfig) = get(tree).isKeep + def keep(tree: Tree): Boolean = get(tree).isKeep } object Infix { 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 685c982cb..c297900dd 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 @@ -1183,7 +1183,7 @@ class Router(formatOps: FormatOps) { if (noSplitMod == null) Seq.empty else if (onlyConfigStyle) Seq( Split(noSplitMod, 0).withPolicy(oneArgOneLine & implicitPolicy) - .withOptimalToken(afterOpen, killOnFail = true) + .withOptimalToken(afterscalaOpen, killOnFail = true) .withIndents(extraOneArgPerLineIndent, indent), ) else { diff --git a/scalafmt-core/shared/src/main/scala/org/scalafmt/util/TreeOps.scala b/scalafmt-core/shared/src/main/scala/org/scalafmt/util/TreeOps.scala index f0aecfdba..0df2cc6d8 100644 --- a/scalafmt-core/shared/src/main/scala/org/scalafmt/util/TreeOps.scala +++ b/scalafmt-core/shared/src/main/scala/org/scalafmt/util/TreeOps.scala @@ -773,7 +773,9 @@ object TreeOps { topSourceTree: Tree, baseStyle: ScalafmtConfig, ): (ScalafmtConfig, collection.Map[TokenHash, Tree]) = { - var infixCount = 0 + var termInfixCount = 0 + var typeInfixCount = 0 + var patInfixCount = 0 // Creates lookup table from token offset to its closest scala.meta tree val ownersMap = HashMap.newBuilder[TokenHash, Tree] @inline @@ -789,7 +791,12 @@ object TreeOps { elemEnd: T, outerPrevLPs: Int, ): Int = { - if (TreeOps.isInfixApp(elem)) infixCount += 1 + elem match { + case _: Term.ApplyInfix => termInfixCount += 1 + case _: Type.ApplyInfix => typeInfixCount += 1 + case _: Pat.ExtractInfix => patInfixCount += 1 + case _ => + } val treeBeg = elemBeg.start val treeEnd = elemEnd.end @@ -888,7 +895,7 @@ object TreeOps { treeAt(0, topSourceTree, allTokens.head, allTokens.last, 0) val checkedNewlines = baseStyle.newlines - .checkInfixConfig(infixCount)(baseStyle) + .checkInfixConfig(termInfixCount, typeInfixCount, patInfixCount)(baseStyle) val initStyle = if (checkedNewlines eq baseStyle.newlines) baseStyle else baseStyle.copy(newlines = checkedNewlines) 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 1e0b7b9ba..c8a7306af 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 @@ -9,7 +9,7 @@ abstract class CommunityScala2Suite(name: String) class CommunityScala2_12Suite extends CommunityScala2Suite("scala-2.12") { - override protected def totalStatesVisited: Option[Int] = Some(42512477) + override protected def totalStatesVisited: Option[Int] = Some(42520687) override protected def builds = Seq(getBuild("v2.12.20", dialects.Scala212, 1277)) @@ -18,7 +18,7 @@ class CommunityScala2_12Suite extends CommunityScala2Suite("scala-2.12") { class CommunityScala2_13Suite extends CommunityScala2Suite("scala-2.13") { - override protected def totalStatesVisited: Option[Int] = Some(52980238) + override protected def totalStatesVisited: Option[Int] = Some(52986574) override protected def builds = Seq(getBuild("v2.13.14", dialects.Scala213, 1287)) 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 57187b631..c3ea62296 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 @@ -9,7 +9,7 @@ abstract class CommunityScala3Suite(name: String) class CommunityScala3_2Suite extends CommunityScala3Suite("scala-3.2") { - override protected def totalStatesVisited: Option[Int] = Some(39189350) + override protected def totalStatesVisited: Option[Int] = Some(39189914) override protected def builds = Seq(getBuild("3.2.2", dialects.Scala32, 791)) @@ -17,7 +17,7 @@ class CommunityScala3_2Suite extends CommunityScala3Suite("scala-3.2") { class CommunityScala3_3Suite extends CommunityScala3Suite("scala-3.3") { - override protected def totalStatesVisited: Option[Int] = Some(42295896) + override protected def totalStatesVisited: Option[Int] = Some(42296538) override protected def builds = Seq(getBuild("3.3.3", dialects.Scala33, 861)) 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 3c653fabb..32781fae6 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_classic.stat @@ -11671,6 +11671,8 @@ object ops { } = macro foo } <<< #4705 term=src, type=many +newlines.infix.typeSite.style = many +=== object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = ??? @@ -11688,18 +11690,11 @@ object Foo { with Align[Option] = ??? - def newStyle: Traverse[ - Option - ] & MonadError[ - Option, - Unit - ] & Alternative[ - Option - ] & CommutativeMonad[ - Option - ] & CoflatMap[Option] & Align[ - Option - ] = + def newStyle: Traverse[Option] & + MonadError[Option, Unit] & + Alternative[Option] & + CommutativeMonad[Option] & + CoflatMap[Option] & Align[Option] = Traverse[Option] & MonadError[ Option, Unit @@ -11714,6 +11709,7 @@ object Foo { <<< #4705 term=some, type=keep maxColumn = 80 newlines.infix.termSite.style = some +newlines.infix.typeSite.style = keep === object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = @@ -11732,15 +11728,16 @@ object Foo { with Align[Option] = ??? - def newStyle: Traverse[Option] & MonadError[Option, Unit] & - Alternative[Option] & CommutativeMonad[Option] & CoflatMap[Option] & - Align[Option] = + def newStyle: Traverse[Option] & MonadError[Option, Unit] & Alternative[ + Option + ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] = Traverse[Option] & MonadError[Option, Unit] & Alternative[Option] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] } <<< #4705 term=keep, type=some maxColumn = 80 newlines.infix.termSite.style = keep +newlines.infix.typeSite.style = some === object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = @@ -11759,9 +11756,9 @@ object Foo { with Align[Option] = ??? - def newStyle: Traverse[Option] & MonadError[Option, Unit] & Alternative[ - Option - ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] = + def newStyle: Traverse[Option] & MonadError[Option, Unit] & + Alternative[Option] & CommutativeMonad[Option] & CoflatMap[Option] & + Align[Option] = Traverse[Option] & MonadError[Option, Unit] & Alternative[ Option ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] 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 e9f491d96..cfb38d322 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_fold.stat @@ -10896,6 +10896,8 @@ object ops { } = macro foo } <<< #4705 term=src, type=many +newlines.infix.typeSite.style = many +=== object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = ??? @@ -10926,6 +10928,7 @@ object Foo { <<< #4705 term=some, type=keep maxColumn = 80 newlines.infix.termSite.style = some +newlines.infix.typeSite.style = keep === object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = @@ -10943,15 +10946,16 @@ object Foo { with CoflatMap[Option] with Align[Option] = ??? - def newStyle: Traverse[Option] & MonadError[Option, Unit] & - Alternative[Option] & CommutativeMonad[Option] & CoflatMap[Option] & - Align[Option] = Traverse[Option] & MonadError[Option, Unit] & - Alternative[Option] & CommutativeMonad[Option] & CoflatMap[Option] & - Align[Option] + def newStyle: Traverse[Option] & MonadError[Option, Unit] & Alternative[ + Option + ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] = + Traverse[Option] & MonadError[Option, Unit] & Alternative[Option] & + CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] } <<< #4705 term=keep, type=some maxColumn = 80 newlines.infix.termSite.style = keep +newlines.infix.typeSite.style = some === object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = @@ -10969,10 +10973,9 @@ object Foo { with CoflatMap[Option] with Align[Option] = ??? - def newStyle: Traverse[Option] & MonadError[Option, Unit] & Alternative[ + def newStyle: Traverse[Option] & MonadError[Option, Unit] & + Alternative[Option] & CommutativeMonad[Option] & CoflatMap[Option] & + Align[Option] = Traverse[Option] & MonadError[Option, Unit] & Alternative[ Option - ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] = - Traverse[Option] & MonadError[Option, Unit] & Alternative[ - Option - ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] + ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] } 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 6c8bae2cb..a2d3003c0 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_keep.stat @@ -11432,6 +11432,8 @@ object ops { } = macro foo } <<< #4705 term=src, type=many +newlines.infix.typeSite.style = many +=== object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = ??? @@ -11449,17 +11451,11 @@ object Foo { with Align[Option] = ??? - def newStyle - : Traverse[Option] & MonadError[ - Option, - Unit - ] & Alternative[ - Option - ] & CommutativeMonad[ - Option - ] & CoflatMap[Option] & Align[ - Option - ] = + def newStyle: Traverse[Option] & + MonadError[Option, Unit] & + Alternative[Option] & + CommutativeMonad[Option] & + CoflatMap[Option] & Align[Option] = Traverse[Option] & MonadError[ Option, Unit @@ -11472,6 +11468,7 @@ object Foo { <<< #4705 term=some, type=keep maxColumn = 80 newlines.infix.termSite.style = some +newlines.infix.typeSite.style = keep === object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = @@ -11490,15 +11487,16 @@ object Foo { with Align[Option] = ??? - def newStyle: Traverse[Option] & MonadError[Option, Unit] & - Alternative[Option] & CommutativeMonad[Option] & CoflatMap[Option] & - Align[Option] = + def newStyle: Traverse[Option] & MonadError[Option, Unit] & Alternative[ + Option + ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] = Traverse[Option] & MonadError[Option, Unit] & Alternative[Option] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] } <<< #4705 term=keep, type=some maxColumn = 80 newlines.infix.termSite.style = keep +newlines.infix.typeSite.style = some === object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = @@ -11517,9 +11515,9 @@ object Foo { with Align[Option] = ??? - def newStyle: Traverse[Option] & MonadError[Option, Unit] & Alternative[ - Option - ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] = + def newStyle: Traverse[Option] & MonadError[Option, Unit] & + Alternative[Option] & CommutativeMonad[Option] & CoflatMap[Option] & + Align[Option] = Traverse[Option] & MonadError[Option, Unit] & Alternative[ Option ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] 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 bfffaec43..8197d69e8 100644 --- a/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat +++ b/scalafmt-tests/shared/src/test/resources/newlines/source_unfold.stat @@ -11875,6 +11875,8 @@ object ops { } = macro foo } <<< #4705 term=src, type=many +newlines.infix.typeSite.style = many +=== object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = ??? @@ -11905,6 +11907,7 @@ object Foo { <<< #4705 term=some, type=keep maxColumn = 80 newlines.infix.termSite.style = some +newlines.infix.typeSite.style = keep === object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = @@ -11922,15 +11925,16 @@ object Foo { with CoflatMap[Option] with Align[Option] = ??? - def newStyle: Traverse[Option] & MonadError[Option, Unit] & - Alternative[Option] & CommutativeMonad[Option] & CoflatMap[Option] & - Align[Option] = + def newStyle: Traverse[Option] & MonadError[Option, Unit] & Alternative[ + Option + ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] = Traverse[Option] & MonadError[Option, Unit] & Alternative[Option] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] } <<< #4705 term=keep, type=some maxColumn = 80 newlines.infix.termSite.style = keep +newlines.infix.typeSite.style = some === object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = @@ -11948,9 +11952,9 @@ object Foo { with CoflatMap[Option] with Align[Option] = ??? - def newStyle: Traverse[Option] & MonadError[Option, Unit] & Alternative[ - Option - ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] = + def newStyle: Traverse[Option] & MonadError[Option, Unit] & + Alternative[Option] & CommutativeMonad[Option] & CoflatMap[Option] & + Align[Option] = Traverse[Option] & MonadError[Option, Unit] & Alternative[ Option ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat index b1f418821..f9d65c97d 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces.stat @@ -8369,6 +8369,8 @@ object a: ) ) <<< #4705 +newlines.infix.typeSite.style = many +=== object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = ??? 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 9e53ffd69..3288fd4ce 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_fold.stat @@ -8034,6 +8034,8 @@ object a: )) ) <<< #4705 +newlines.infix.typeSite.style = many +=== object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = ??? diff --git a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat index 4fb0ba5a7..ae29dbd66 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_keep.stat @@ -8392,6 +8392,8 @@ object a: ) ) <<< #4705 +newlines.infix.typeSite.style = many +=== object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = ??? @@ -8406,9 +8408,9 @@ object Foo { with CoflatMap[Option] with Align[Option] = ??? - def newStyle: Traverse[Option] & MonadError[Option, Unit] & Alternative[ - Option - ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] = + def newStyle: Traverse[Option] & MonadError[Option, Unit] & + Alternative[Option] & CommutativeMonad[Option] & CoflatMap[Option] & + Align[Option] = Traverse[Option] & MonadError[Option, Unit] & Alternative[ Option ] & CommutativeMonad[Option] & CoflatMap[Option] & Align[Option] 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 b9d1ab6d0..e85d4cd21 100644 --- a/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat +++ b/scalafmt-tests/shared/src/test/resources/scala3/OptionalBraces_unfold.stat @@ -8716,6 +8716,8 @@ object a: ) ) <<< #4705 +newlines.infix.typeSite.style = many +=== object Foo { def oldStyle: Traverse[Option] with MonadError[Option, Unit] with Alternative[Option] with CommutativeMonad[Option] with CoflatMap[Option] with Align[Option] = ??? 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 c5ceda9c2..dcfa1848e 100644 --- a/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala +++ b/scalafmt-tests/shared/src/test/scala/org/scalafmt/FormatTests.scala @@ -144,7 +144,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, 1252077, "total explored") + assertEquals(explored, 1251945, "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 :'(