Repository: scalameta/scalameta (scala)

Issue:
Allow removeOptionalBraces for test cases with Scala 3.3.0 Version
With the new Scala 3.3.0 version, we can now replace
```
test ("………") {
}
```
with
```
test ("……….") :
```
The complier is happy.
However, Scala fmt sbt plugin is not happy with it. Does anyone know how to add the such rule for tests in `.scalafmt.conf` file? It’s not to format the test codes automatically to that style, it’s to allow such change by human.

Pull request description:
Fixes #3164. By making it explicitly invalid...

Patch:
diff --git a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
index 7df56a67c0..2d713a0874 100644
--- a/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
+++ b/scalameta/parsers/shared/src/main/scala/scala/meta/internal/parsers/ScalametaParser.scala
@@ -1616,7 +1616,7 @@ class ScalametaParser(input: Input)(implicit dialect: Dialect) { parser =>
     } else if (token.is[Colon] && dialect.allowFewerBraces && isEolAfter(tokenPos)) {
       val colonPos = tokenPos
       next()
-      in.observeIndented()
+      if (!in.observeIndented()) syntaxError("expected fewer-braces method body", prevToken)
       val args = blockExpr(allowRepeated = false)
       val argClause = autoEndPos(colonPos)(Term.ArgClause(args :: Nil))
       val arguments = addPos(Term.Apply(t, argClause))
@@ -2232,7 +2232,7 @@ class ScalametaParser(input: Input)(implicit dialect: Dialect) { parser =>
         // map:
         val argsOpt = if (isEolAfter(colonPos)) Some {
           next()
-          in.observeIndented()
+          if (!in.observeIndented()) syntaxError("expected fewer-braces method body", prevToken)
           blockExpr(allowRepeated = false)
         }
         else


Test patch:
diff --git a/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/FewerBracesSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/FewerBracesSuite.scala
index 49626dfc75..a6a3da46af 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/FewerBracesSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/parsers/dotty/FewerBracesSuite.scala
@@ -628,45 +628,25 @@ class FewerBracesSuite extends BaseDottySuite {
   }
 
   test("#3164 empty argument 1") {
-    runTestAssert[Stat](
+    runTestError[Stat](
       """|object a:
          |  test("foo"):
          |""".stripMargin,
-      Some("""object a { test("foo") {} }""")
-    )(
-      Defn.Object(
-        Nil,
-        tname("a"),
-        Template(
-          Nil,
-          Nil,
-          slf,
-          List(Term.Apply(Term.Apply(tname("test"), List(str("foo"))), List(Term.Block(Nil)))),
-          Nil
-        )
-      )
+      """|<input>:2: error: expected fewer-braces method body
+         |  test("foo"):
+         |             ^""".stripMargin
     )
   }
 
   test("#3164 empty argument 2") {
-    runTestAssert[Stat](
+    runTestError[Stat](
       """|object a:
          |  foo :
          |  bar
          |""".stripMargin,
-      Some("object a { foo(bar) }")
-    )(
-      Defn.Object(
-        Nil,
-        tname("a"),
-        Template(
-          Nil,
-          Nil,
-          slf,
-          List(Term.Apply(tname("foo"), List(tname("bar")))),
-          Nil
-        )
-      )
+      """|<input>:2: error: expected fewer-braces method body
+         |  foo :
+         |      ^""".stripMargin
     )
   }