PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: scalameta/scalameta (scala)

Issue:
Scalameta 4.8.11 update broke javadoc-like links in scaladocs
Test case: https://github.com/scalameta/scalafmt/compare/master...lrytz:scalafmt:java-tag-bug?expand=1

In
```scala
/**
 * Text {@foo bar baz} bam.
 */
```

`{@foo bar baz}` is reformatted to `{@@foobar baz}`. This regressed in https://github.com/scalameta/scalafmt/commit/503255c6483af003532e48c2c880c30526d00756, quite certainly due to https://github.com/scalameta/scalameta/pull/3342.

It's not uncommon in a mixed codebase to come across `{@link target}` in scaladoc comments.

Pull request:
Fixes #3392.

Patch:
diff --git a/scalameta/trees/shared/src/main/scala/scala/meta/internal/Scaladoc.scala b/scalameta/trees/shared/src/main/scala/scala/meta/internal/Scaladoc.scala
index 1091b09635..a26880f946 100644
--- a/scalameta/trees/shared/src/main/scala/scala/meta/internal/Scaladoc.scala
+++ b/scalameta/trees/shared/src/main/scala/scala/meta/internal/Scaladoc.scala
@@ -49,7 +49,7 @@ object Scaladoc {
 
   /** Represents an enclosed tagged documentation remark */
   final case class EnclosedJavaTag(tag: String, desc: Seq[String] = Nil) extends TextPart {
-    override def syntax: String = desc.mkString(s"{@$tag", " ", "}")
+    override def syntax: String = (tag +: desc).mkString("{", " ", "}")
   }
 
   /** A block of one or more lines of code */


Test patch:
diff --git a/tests/shared/src/test/scala/scala/meta/tests/parsers/ScaladocParserSuite.scala b/tests/shared/src/test/scala/scala/meta/tests/parsers/ScaladocParserSuite.scala
index 70a00d2e54..92e4d957af 100644
--- a/tests/shared/src/test/scala/scala/meta/tests/parsers/ScaladocParserSuite.scala
+++ b/tests/shared/src/test/scala/scala/meta/tests/parsers/ScaladocParserSuite.scala
@@ -1857,6 +1857,8 @@ class ScaladocParserSuite extends FunSuite {
   }
 
   test("enclosed java tag") {
+    val javaTag1 = EnclosedJavaTag("@tag1")
+    val javaTag2 = EnclosedJavaTag("@tag2", List("with", "desc"))
     assertEquals(
       parseString(
         """
@@ -1873,8 +1875,8 @@ class ScaladocParserSuite extends FunSuite {
           Paragraph(
             Text(
               Seq(
-                EnclosedJavaTag("@tag1"),
-                EnclosedJavaTag("@tag2", List("with", "desc")),
+                javaTag1,
+                javaTag2,
                 Word("{@not"),
                 Word("a"),
                 Word("tag}")
@@ -1884,6 +1886,8 @@ class ScaladocParserSuite extends FunSuite {
         )
       )
     )
+    assertEquals(javaTag1.syntax, "{@tag1}")
+    assertEquals(javaTag2.syntax, "{@tag2 with desc}")
   }
 
   test("table escaped pipe") {