From 39132a18e4a30fd860ce95192b5cb8c98e44c928 Mon Sep 17 00:00:00 2001 From: Albert Meltzer <7529386+kitbellew@users.noreply.github.com> Date: Sat, 18 Sep 2021 09:08:07 -0700 Subject: [PATCH] TreeOps: classify Type.Apply only as isCallSite It was also present in isDefnSite. --- .../src/main/scala/org/scalafmt/internal/Router.scala | 2 +- .../shared/src/main/scala/org/scalafmt/util/TreeOps.scala | 6 +++--- scalafmt-tests/src/test/resources/scalajs/Class.stat | 4 ++-- scalafmt-tests/src/test/resources/scalajs/DefDef.stat | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) 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 50b3d5add3..a5f0a96404 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 @@ -827,7 +827,7 @@ class Router(formatOps: FormatOps) { val defnSite = !tupleSite && anyDefnSite val indent = - if (anyDefnSite && !leftOwner.isInstanceOf[Type.Apply]) + if (anyDefnSite) Num(style.indent.getDefnSite(leftOwner)) else Num(style.indent.callSite) 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 6c470442fd..83efec2892 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 @@ -399,9 +399,9 @@ object TreeOps { tree match { case _: Decl.Def | _: Defn.Def | _: Defn.Macro | _: Defn.Class | _: Defn.Trait | _: Ctor.Secondary | _: Decl.Type | _: Defn.Type | - _: Type.Apply | _: Type.Param | _: Type.Tuple | _: Defn.Enum | - _: Defn.EnumCase | _: Defn.ExtensionGroup | _: Decl.Given | - _: Defn.Given | _: Defn.GivenAlias => + _: Type.Param | _: Type.Tuple | _: Defn.Enum | _: Defn.EnumCase | + _: Defn.ExtensionGroup | _: Decl.Given | _: Defn.Given | + _: Defn.GivenAlias => true case _: Term.FunctionTerm | _: Type.FunctionType => true case _: Term.PolyFunction | _: Type.PolyFunction => true diff --git a/scalafmt-tests/src/test/resources/scalajs/Class.stat b/scalafmt-tests/src/test/resources/scalajs/Class.stat index 7cb57ad925..5d8cd16d01 100644 --- a/scalafmt-tests/src/test/resources/scalajs/Class.stat +++ b/scalafmt-tests/src/test/resources/scalajs/Class.stat @@ -43,8 +43,8 @@ class Promise[+A]( executor: js.Function2[js.Function1[A | Thenable[A], _], js.Function1[scala.Any, _], _]) >>> class Promise[+A]( - executor: js.Function2[ - js.Function1[A | Thenable[A], _], js.Function1[scala.Any, _], _]) + executor: js.Function2[js.Function1[A | Thenable[A], _], js.Function1[ + scala.Any, _], _]) <<< #270 object a { private class Encoder extends CharsetEncoder( diff --git a/scalafmt-tests/src/test/resources/scalajs/DefDef.stat b/scalafmt-tests/src/test/resources/scalajs/DefDef.stat index c066c697ef..0413d39b1a 100644 --- a/scalafmt-tests/src/test/resources/scalajs/DefDef.stat +++ b/scalafmt-tests/src/test/resources/scalajs/DefDef.stat @@ -201,7 +201,7 @@ implicit def toFunction22[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, js.Array[JSStackTraceElem], js.Array[JSStackTraceElem]]] = js.native >>> def sourceMapper: js.UndefOr[js.Function1[ // scalastyle:ignore - js.Array[JSStackTraceElem], js.Array[JSStackTraceElem]]] = js.native + js.Array[JSStackTraceElem], js.Array[JSStackTraceElem]]] = js.native <<< comment inside middle of type parameter #264 3 def sourceMapper: js.UndefOr[ // scalastyle:ignore js.Array[JSStackTraceElem], js.Array[JSStackTraceElem]] = js.native