Repository: scalameta/scalameta (scala)

Issue:
Please publish for Scala 2.13.16
which is now on Maven Central, as per https://contributors.scala-lang.org/t/scala-2-13-16-release-planning/6773/21

Pull request description:
Fixes https://github.com/scalameta/scalameta/issues/4128

Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 58b7c40a0f..19948cf5b0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -12,7 +12,7 @@ jobs:
       fail-fast: false
       matrix:
         command:
-          - "++2.13.15; download-scala-library; testsSemanticdb/test"
+          - "++2.13.16; download-scala-library; testsSemanticdb/test"
           - "communitytest/test"
           - "mima"
     steps:
@@ -38,11 +38,21 @@ jobs:
           - 'Native'
         scala:
           - '2.12.20'
-          - '2.13.15'
+          - '2.13.16'
           - '3.3.4'
         java:
           - '8'
           - '17'
+        exclude:
+          - type: 'JS'
+            scala: '2.13.16'
+        include:
+          - type: 'JS'
+            scala: '2.13.15'
+            java: 17
+          - type: 'JS'
+            scala: '2.13.15'
+            java: 8
     steps:
       - uses: actions/checkout@v4
         with:
@@ -69,9 +79,9 @@ jobs:
           - '2.12.16'
           - '2.12.17'
           - '2.12.18'
-          - '2.13.12'
           - '2.13.13'
           - '2.13.14'
+          - '2.13.15'
     steps:
       - uses: actions/checkout@v4
         with:
diff --git a/build.sbt b/build.sbt
index d3e340ef14..5a6f6ae6f3 100644
--- a/build.sbt
+++ b/build.sbt
@@ -77,8 +77,8 @@ Global / resolvers +=
   "scala-integration".at("https://scala-ci.typesafe.com/artifactory/scala-integration/")
 
 val commonJsSettings = Seq(
-  crossScalaVersions := List(LatestScala213, LatestScala212),
-  scalaVersion := LatestScala213,
+  crossScalaVersions := List(LatestScala213ForJS, LatestScala212),
+  scalaVersion := LatestScala213ForJS,
   bspEnabled := false,
   scalaJSLinkerConfig := StandardConfig().withBatchMode(true),
   scalacOptions ++= {
diff --git a/project/Versions.scala b/project/Versions.scala
index c5ec013e6c..1bde8e01aa 100644
--- a/project/Versions.scala
+++ b/project/Versions.scala
@@ -4,11 +4,12 @@ package build
 object Versions {
   val Scala211Versions = getVersions(2, 11, 12 to 12)
   val Scala212Versions = getVersions(2, 12, 17 to 20)
-  val Scala213Versions = getVersions(2, 13, 12 to 15)
+  val Scala213Versions = getVersions(2, 13, 13 to 16)
   val Scala3Version = "3.3.4"
   val LatestScala211 = Scala211Versions.head
   val LatestScala212 = Scala212Versions.head
   val LatestScala213 = Scala213Versions.head
+  val LatestScala213ForJS = "2.13.15"
   val EarliestScala211 = Scala211Versions.last
   val EarliestScala212 = Scala212Versions.last
   val EarliestScala213 = Scala213Versions.last
diff --git a/semanticdb/scalac/library/src/main/scala/scala/meta/internal/semanticdb/scalac/TextDocumentOps.scala b/semanticdb/scalac/library/src/main/scala/scala/meta/internal/semanticdb/scalac/TextDocumentOps.scala
index b72dc7956a..75c7dac34d 100644
--- a/semanticdb/scalac/library/src/main/scala/scala/meta/internal/semanticdb/scalac/TextDocumentOps.scala
+++ b/semanticdb/scalac/library/src/main/scala/scala/meta/internal/semanticdb/scalac/TextDocumentOps.scala
@@ -141,7 +141,14 @@ trait TextDocumentOps {
             names.result()
           }
           private def indexArgNames(mapp: m.Tree): Unit = mapp match {
-            case t: m.Init => margnames(t.pos.start) = getAssignLhsAndIndexRhs(t.argClauses)
+            case t: m.Init =>
+              val names = getAssignLhsAndIndexRhs(t.argClauses)
+              margnames(t.pos.start) = names
+              // 2.13.16 changed position
+              t.parent.foreach {
+                case n: m.Term.New => margnames(n.pos.start) = names
+                case _ =>
+              }
 
             case t: m.Term.Apply =>
               margnames(t.fun.pos.end) = getAssignLhsAndIndexRhs(t.argClause :: Nil)


Test patch:
diff --git a/tests-semanticdb/src/test/resources/metac.expect_2.13 b/tests-semanticdb/src/test/resources/metac.expect_2.13
index 731ade3f45..4209657aa3 100644
--- a/tests-semanticdb/src/test/resources/metac.expect_2.13
+++ b/tests-semanticdb/src/test/resources/metac.expect_2.13
@@ -455,7 +455,7 @@ Occurrences:
 [42:21..42:25): head => scala/collection/IterableOps#head().
 
 Diagnostics:
-[3:0..3:33) [warning] Unused import of deprecated lazy value higherKinds: higherKinds no longer needs to be imported explicitly
+[3:22..3:33) [warning] Unused import of deprecated lazy value higherKinds: higherKinds no longer needs to be imported explicitly
 
 Synthetics:
 [39:2..39:9): locally => *[Unit]
@@ -651,7 +651,7 @@ Occurrences:
 [16:10..16:10):  => java/lang/Object#`<init>`().
 
 Diagnostics:
-[1:0..1:33) [warning] Unused import of deprecated lazy value higherKinds: higherKinds no longer needs to be imported explicitly
+[1:22..1:33) [warning] Unused import of deprecated lazy value higherKinds: higherKinds no longer needs to be imported explicitly
 [6:15..6:15) [warning] Top-level wildcard is not allowed
 
 Synthetics:
@@ -1754,7 +1754,10 @@ Synthetics:
     b <- List(1)
     if b > 1
     c = a + b
-  } yield (a, b, c) => orig(List(1)).flatMap[Tuple3[Int, Int, Int]]({(a) => orig(List(1)).withFilter({(b) => orig(b > 1)}).map[Tuple2[Int, Int]]({(b) => orig(c = a + b)}).map[Tuple3[Int, Int, Int]]({(local2) => orig((a, b, c))})})
+  } yield (a, b, c) => orig(List(1)).flatMap[Tuple3[Int, Int, Int]]({(a) => orig(List(1)).withFilter({(b) => orig(b > 1)}).map[Tuple2[Int, Int]]({(b) => orig(c = a + b)}).map[Tuple3[Int, Int, Int]]({(local2) => orig(b <- List(1)
+    if b > 1
+    c = a + b
+  } yield (a, b, c))})})
   flatMap => scala/collection/immutable/List#flatMap().
   Tuple3 => scala/Tuple3#
   Int => scala/Int#
@@ -1816,12 +1819,55 @@ Synthetics:
       b,
       c,
       d
-    ) == (1, 2, 3, 4))}).map[Tuple2[Tuple2[Int, Int], Tuple4[Int, Int, Int, Int]]]({(local8) => orig(e = (
+    ) == (1, 2, 3, 4))}).map[Tuple2[Tuple2[Int, Int], Tuple4[Int, Int, Int, Int]]]({(local8) => orig((
+      c,
+      d
+    ) <- List((a, b))
+    if (
+      a,
+      b,
+      c,
+      d
+    ) == (1, 2, 3, 4)
+    e = (
+      a,
+      b,
+      c,
+      d
+    ))}).withFilter({(local9) => orig((
+      c,
+      d
+    ) <- List((a, b))
+    if (
+      a,
+      b,
+      c,
+      d
+    ) == (1, 2, 3, 4)
+    e = (
+      a,
+      b,
+      c,
+      d
+    )
+    if e == (1, 2, 3, 4))}).flatMap[Tuple6[Int, Int, Int, Int, Tuple4[Int, Int, Int, Int], Tuple4[Int, Int, Int, Int]]]({(local10) => orig((
+      c,
+      d
+    ) <- List((a, b))
+    if (
+      a,
+      b,
+      c,
+      d
+    ) == (1, 2, 3, 4)
+    e = (
       a,
       b,
       c,
       d
-    ))}).withFilter({(local9) => orig(e == (1, 2, 3, 4))}).flatMap[Tuple6[Int, Int, Int, Int, Tuple4[Int, Int, Int, Int], Tuple4[Int, Int, Int, Int]]]({(local10) => orig(f <- List(e)
+    )
+    if e == (1, 2, 3, 4)
+    f <- List(e)
   } yield {
     (
       a,
@@ -2187,7 +2233,7 @@ Occurrences:
 [26:22..26:29): classOf => scala/Predef.classOf().
 
 Diagnostics:
-[4:0..4:33) [warning] Unused import of deprecated lazy value higherKinds: higherKinds no longer needs to be imported explicitly
+[4:22..4:33) [warning] Unused import of deprecated lazy value higherKinds: higherKinds no longer needs to be imported explicitly
 
 Synthetics:
 [8:12..8:16): List => *.apply[Any]
@@ -5414,7 +5460,7 @@ Occurrences:
 [119:36..119:39): T#C => types/T#C#
 
 Diagnostics:
-[3:0..3:33) [warning] Unused import of deprecated lazy value higherKinds: higherKinds no longer needs to be imported explicitly
+[3:22..3:33) [warning] Unused import of deprecated lazy value higherKinds: higherKinds no longer needs to be imported explicitly
 
 semanticdb/integration/src/main/scala/example/ValPattern.scala
 --------------------------------------------------------------
diff --git a/tests-semanticdb/src/test/scala/scala/meta/tests/semanticdb/TargetedSuite.scala b/tests-semanticdb/src/test/scala/scala/meta/tests/semanticdb/TargetedSuite.scala
index e81a51c0b2..073eb015c1 100644
--- a/tests-semanticdb/src/test/scala/scala/meta/tests/semanticdb/TargetedSuite.scala
+++ b/tests-semanticdb/src/test/scala/scala/meta/tests/semanticdb/TargetedSuite.scala
@@ -238,6 +238,81 @@ class TargetedSuite extends SemanticdbSuite {
     }
   )
 
+  test("named-args") {
+    val code = """|@deprecated(since = "123")
+                  |class CLS(name: String) {
+                  |  def this(name2: Int) = this(name = name2.toString)
+                  |}
+                  |""".stripMargin
+    val expected = """|Summary:
+                      |Schema => SemanticDB v4
+                      |Text => non-empty
+                      |Language => Scala
+                      |Symbols => 8 entries
+                      |Occurrences => 14 entries
+                      |
+                      |Symbols:
+                      |_empty_/CLS# => @deprecated class CLS extends AnyRef { +3 decls }
+                      |  deprecated => scala/deprecated#
+                      |  AnyRef => scala/AnyRef#
+                      |_empty_/CLS#`<init>`(). => primary ctor <init>(name: String)
+                      |  name => _empty_/CLS#`<init>`().(name)
+                      |  String => scala/Predef.String#
+                      |_empty_/CLS#`<init>`().(name) => param name: String
+                      |  String => scala/Predef.String#
+                      |_empty_/CLS#`<init>`(+1). => ctor <init>(name2: Int)
+                      |  name2 => _empty_/CLS#`<init>`(+1).(name2)
+                      |  Int => scala/Int#
+                      |_empty_/CLS#`<init>`(+1).(name2) => param name2: Int
+                      |  Int => scala/Int#
+                      |_empty_/CLS#name. => private[this] val method name: String
+                      |  String => scala/Predef.String#
+                      |local0 => val local x$1: "123"
+                      |local1 => val local x$2: String
+                      |  String => scala/Predef.String#
+                      |
+                      |Occurrences:
+                      |[0:1..0:11): deprecated => _empty_/
+                      |[0:11..0:11):  => scala/deprecated#`<init>`().
+                      |[0:12..0:17): since => scala/deprecated#`<init>`().(since)
+                      |[1:6..1:9): CLS <= _empty_/CLS#
+                      |[1:9..1:9):  <= _empty_/CLS#`<init>`().
+                      |[1:10..1:14): name <= _empty_/CLS#name.
+                      |[1:16..1:22): String => scala/Predef.String#
+                      |[2:6..2:10): this <= _empty_/CLS#`<init>`(+1).
+                      |[2:11..2:16): name2 <= _empty_/CLS#`<init>`(+1).(name2)
+                      |[2:18..2:21): Int => scala/Int#
+                      |[2:29..2:29):  => _empty_/CLS#`<init>`().
+                      |[2:30..2:34): name => _empty_/CLS#`<init>`().(name)
+                      |[2:37..2:42): name2 => _empty_/CLS#`<init>`(+1).(name2)
+                      |[2:43..2:51): toString => scala/Any#toString().
+                      |""".stripMargin
+
+    val expectedCompat =
+      if (isScala213) expected
+      else expected
+        .replace("Occurrences => 14 entries", "Occurrences => 14 entries\nDiagnostics => 1 entries")
+        .replace(
+          "local0 => val local x$1: \"123\"",
+          """|local0 => val local x$1: String
+             |  String => java/lang/String#""".stripMargin
+        ).replace(
+          "[0:1..0:11): deprecated => _empty_/",
+          "[0:1..0:11): deprecated => scala/deprecated#" // TODO https://github.com/scalameta/scalameta/issues/4136
+        ) + "\n" +
+        """|Diagnostics:
+           |[0:1..0:26) [warning] Usage of named or default arguments transformed this annotation
+           |constructor call into a block. The corresponding AnnotationInfo
+           |will contain references to local values and default getters instead
+           |of the actual argument trees
+           |""".stripMargin
+    assertEquals(
+      computePayloadFromSnippet(code).linesIterator.drop(3).filter(!_.startsWith("Uri => "))
+        .mkString("", "\n", "\n"),
+      expectedCompat
+    )
+  }
+
   locally { // #3738
     val code = """|trait AmbiguousMend {
                   |  def x
@@ -267,5 +342,4 @@ class TargetedSuite extends SemanticdbSuite {
       )
     }
   }
-
 }