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 698576e4c0..a6aa391711 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 @@ -1290,19 +1290,21 @@ class FormatOps( Seq(slbSplit, noSplit.andPolicy(noSlbPolicy), nlSplit) } else { val rightIsImplicit = r.is[soft.ImplicitOrUsing] - val opensImplicit = rightIsImplicit && - getImplicitParamList(ft.meta.rightOwner).exists(_.lengthCompare(1) > 0) val nlOnly = if (rightIsImplicit) style.newlines.forceBeforeImplicitParamListModifier else style.verticalMultiline.newlineAfterOpenParen + val implicitParams = + if (!rightIsImplicit) Nil + else getImplicitParamList(ft.meta.rightOwner).getOrElse(Nil) val noSlb = nlOnly || aboveArityThreshold || ft.hasBreak && !style.newlines.sourceIgnored && style.optIn.configStyleArguments || - opensImplicit && style.newlines.forceAfterImplicitParamListModifier + implicitParams.nonEmpty && + style.newlines.forceAfterImplicitParamListModifier val nlMod = NewlineT(alt = if (nlOnly) None else Some(slbSplit.modExt)) - val spaceImplicit = - opensImplicit && style.newlines.notBeforeImplicitParamListModifier + val spaceImplicit = !nlOnly && implicitParams.lengthCompare(1) > 0 && + style.newlines.notBeforeImplicitParamListModifier Seq( // If we can fit all in one block, make it so slbSplit.notIf(noSlb), diff --git a/scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat b/scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat index a2a87aa961..00b514976c 100644 --- a/scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat +++ b/scalafmt-tests/src/test/resources/scala3/OptionalBraces.stat @@ -4259,7 +4259,10 @@ object a: def f[A](a: A, as: A*)[B]( b: B, bs: B* - )[C](implicit c: C): B = ??? + )[C]( + implicit + c: C + ): B = ??? class F( a: A, as: A* diff --git a/scalafmt-tests/src/test/resources/scala3/OptionalBraces_fold.stat b/scalafmt-tests/src/test/resources/scala3/OptionalBraces_fold.stat index 60d746a4de..3bd1fd3abd 100644 --- a/scalafmt-tests/src/test/resources/scala3/OptionalBraces_fold.stat +++ b/scalafmt-tests/src/test/resources/scala3/OptionalBraces_fold.stat @@ -4070,7 +4070,10 @@ object a: def f[A](a: A, as: A*)[B]( b: B, bs: B* - )[C](implicit c: C): B = ??? + )[C]( + implicit + c: C + ): B = ??? class F( a: A, as: A* diff --git a/scalafmt-tests/src/test/resources/scala3/OptionalBraces_keep.stat b/scalafmt-tests/src/test/resources/scala3/OptionalBraces_keep.stat index 823f39c737..257424b8fb 100644 --- a/scalafmt-tests/src/test/resources/scala3/OptionalBraces_keep.stat +++ b/scalafmt-tests/src/test/resources/scala3/OptionalBraces_keep.stat @@ -4298,7 +4298,10 @@ object a: def f[A](a: A, as: A*)[B]( b: B, bs: B* - )[C](implicit c: C): B = ??? + )[C]( + implicit + c: C + ): B = ??? class F( a: A, as: A* diff --git a/scalafmt-tests/src/test/resources/scala3/OptionalBraces_unfold.stat b/scalafmt-tests/src/test/resources/scala3/OptionalBraces_unfold.stat index b26aa3d177..29c70664e3 100644 --- a/scalafmt-tests/src/test/resources/scala3/OptionalBraces_unfold.stat +++ b/scalafmt-tests/src/test/resources/scala3/OptionalBraces_unfold.stat @@ -4390,7 +4390,10 @@ object a: def f[A](a: A, as: A*)[B]( b: B, bs: B* - )[C](implicit c: C): B = ??? + )[C]( + implicit + c: C + ): B = ??? class F( a: A, as: A*