scalameta / scalafmt

Code formatter for Scala
http://scalameta.org/scalafmt
Apache License 2.0
1.43k stars 277 forks source link

RedundantParens removes parens around cats `FunctionK` that are necessary #4122

Closed mrdziuban closed 3 months ago

mrdziuban commented 3 months ago

Configuration (required)

version = "3.8.3"
runner.dialect = scala3
rewrite.rules = [RedundantParens]

Command-line parameters (required)

When I run scalafmt via CLI like this: scalafmt -c .scalafmt.conf test.scala

Steps

Given code like this:

new (Const[String, *] ~> ([a] =>> IO[Const[Int, a]])) {
  def apply[A](a: Const[String, A]): IO[Const[Int, A]] =
    IO.pure(Const(a.getConst.length))
}

Problem

Scalafmt formats code like this:

new Const[String, *] ~> ([a] =>> IO[Const[Int, a]]) {
  def apply[A](a: Const[String, A]): IO[Const[Int, A]] =
    IO.pure(Const(a.getConst.length))
}

Expectation

I would like the formatted output to remain unchanged -- the parentheses around the new (...) are necessary.