Repository: scalameta/scalameta (scala)

Issue:
Invalid symbol occurrence for pattern match var binder
```scala
var List(x) = List(1)
```

```diff
- obtained
+ expected
Symbols:
b/a.x(). => var method x: Int
Occurrences:
[2:6..2:10) => scala/collection/immutable/List.
- [2:11..2:12) <= b/a.x.
+ [2:11..2:12) <= b/a.x().
[2:16..2:20) => scala/collection/immutable/List.
```

Reported by @wiwa in https://gitter.im/scalacenter/scalafix?at=5cf54157f3a60a79a449052e

Pull request description:
Current logic handles only a `val` with a top-level Extract pattern but not one with a nested Extract. Fixes #1872.

Patch:
diff --git a/semanticdb/integration/src/main/scala/example/Issue1872.scala b/semanticdb/integration/src/main/scala/example/Issue1872.scala
new file mode 100644
index 0000000000..c6661d1a2f
--- /dev/null
+++ b/semanticdb/integration/src/main/scala/example/Issue1872.scala
@@ -0,0 +1,13 @@
+package example
+
+object Issue1872 {
+
+  val List(a1_1) = List(1)
+
+  val a2_1, List(/*a2*/ a2_2) = List(1, 2)
+  val b2_1, List(/*b2*/ b2_2: Int) = List(1, 2)
+  val c2_1, List(/*c2*/ c2_2 @ _) = List(1, 2)
+
+  val a3_1, List(a3_2, a3_3) = List(1, 2, 3)
+
+}
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 1316ac856d..09e34dab59 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
@@ -78,6 +78,8 @@ trait TextDocumentOps {
 
       def addPatOccurrenceFromSemantic(mpos: m.Position, ssym: String): Unit =
         if (ssym != Symbols.None) mpatoccurrences.update(mpos, (ssym, Role.DEFINITION))
+      def addPatOccurrence(mpos: m.Position, gsym: g.Symbol): Unit =
+        addPatOccurrenceFromSemantic(mpos, gsym.toSemantic)
 
       locally {
         object traverser extends m.Traverser {
@@ -130,15 +132,24 @@ trait TextDocumentOps {
                 mwithins.put(menclName, mname).foreach(errorAmbiguous("mWithins", mname, _))
             }
           }
-          // Map the start position of the entire Defn.Val `val Foo(name) = ..` to the `name` position.
-          // This is needed to handle val patterns with a single binder since the position of `x` in the
-          // desugared `val x = ... match { case Foo(_x) => _x }` matches the position of Defn.Val
-          // and not `_x`.
-          def indexPats(pats: List[m.Pat], mpos: Int): Unit = pats.foreach(_.traverse {
-            // TODO: handle Pat.Extract
-            case pat: m.Pat.Var =>
-              val npos = pat.name.pos; mvalpatstart += npos.start; msinglevalpats(mpos) = npos
+          def indexPats(pats: List[m.Pat]): Unit = pats.foreach(_.traverse {
+            case pat: m.Pat.Extract => indexPatsWithExtract(pat)
+            case pat: m.Pat.Var => mvalpatstart += pat.name.pos.start
           })
+          // In an Extract pattern `Foo(name) = ...`, let's map the end position of the `fun` field
+          // to the `name` position. Compiler desugars it into a getter DefDef and specifically
+          // in the case of a single binder sets the position of this getter as an OffsetPosition
+          // pointing to "end of fun" rather than the field being extracted.
+          def indexPatsWithExtract(extract: m.Pat.Extract): Unit = extract.args match {
+            case pat :: Nil =>
+              val mpos = extract.fun.pos.end
+              pat.traverse {
+                case pat: m.Pat.Extract => indexPatsWithExtract(pat)
+                case pat: m.Pat.Var =>
+                  val npos = pat.name.pos; mvalpatstart += npos.start; msinglevalpats(mpos) = npos
+              }
+            case pats => indexPats(pats)
+          }
           override def apply(mtree: m.Tree): Unit = {
             mtree match {
               case mtree: m.Term.Apply => indexArgNames(mtree)
@@ -152,7 +163,7 @@ trait TextDocumentOps {
               case mtree: m.Name => indexName(mtree)
               case mtree: m.Tree.WithPats => mtree.pats match {
                   case (_: m.Pat.Var) :: Nil =>
-                  case pats => indexPats(pats, mtree.pos.start)
+                  case pats => indexPats(pats)
                 }
               case _ =>
             }
@@ -312,7 +323,12 @@ trait TextDocumentOps {
                 // then its positions are completely mental, so we just hack around
                 tryMstart(gpoint + 7)
                 tryMstart(gpoint)
-              case gtree: g.ValDef =>
+              case _: g.DefDef if gsym.isGetter =>
+                msinglevalpats.get(gpoint) match {
+                  case Some(mpos) => addPatOccurrence(mpos, gsym)
+                  case _ => tryMstart(gpoint)
+                }
+              case _: g.ValDef =>
                 if (!gsym.isMethod && gsym.getterIn(gsym.owner) != g.NoSymbol) {
                   // FIXME: https://github.com/scalameta/scalameta/issues/1538
                   // Skip the field definition in favor of the associated getter.
@@ -322,11 +338,6 @@ trait TextDocumentOps {
                   tryMstart(gstart)
                   tryMstart(gpoint)
                 }
-                // Map Defn.Val position of val pattern with single binder to the position
-                // of the single binder. For example, map `val Foo(x) = ..` to the position of `x`.
-                // checked above, under MemberDef, that it's not isSynthetic anymore
-                if (gpos.isRange) msinglevalpats.get(gstart)
-                  .foreach(addOccurrence(_, gsym, Role.DEFINITION))
               case gtree: g.MemberDef => tryMstart(gpoint)
               case gtree: g.DefTree => tryMstart(gpoint)
               case gtree: g.This


Test patch:
diff --git a/tests-semanticdb/src/test/resources/example/Issue1872_2.12.scala b/tests-semanticdb/src/test/resources/example/Issue1872_2.12.scala
new file mode 100644
index 0000000000..e94ef2fa65
--- /dev/null
+++ b/tests-semanticdb/src/test/resources/example/Issue1872_2.12.scala
@@ -0,0 +1,13 @@
+package example
+
+object Issue1872/*<=example.Issue1872.*/ {
+
+  val List/*=>scala.collection.immutable.List.*/(a1_1/*<=example.Issue1872.a1_1.*/) = List/*=>scala.collection.immutable.List.*/(1)
+
+  val a2_1/*<=example.Issue1872.a2_1.*/, List/*=>scala.collection.immutable.List.*/(/*a2*/ a2_2/*<=example.Issue1872.a2_2.*/) = List/*=>scala.collection.immutable.List.*/(1, 2)
+  val b2_1/*<=example.Issue1872.b2_1.*/, List/*=>scala.collection.immutable.List.*/(/*b2*/ b2_2/*<=example.Issue1872.b2_2.*/: Int/*=>scala.Int#*/) = List/*=>scala.collection.immutable.List.*/(1, 2)
+  val c2_1/*<=example.Issue1872.c2_1.*/, List/*=>scala.collection.immutable.List.*/(/*c2*/ c2_2/*<=example.Issue1872.c2_2.*/ @ _) = List/*=>scala.collection.immutable.List.*/(1, 2)
+
+  val a3_1/*<=example.Issue1872.a3_1.*/, List/*=>scala.collection.immutable.List.*/(a3_2/*<=example.Issue1872.a3_2.*/, a3_3/*<=example.Issue1872.a3_3.*/) = List/*=>scala.collection.immutable.List.*/(1, 2, 3)
+
+}
diff --git a/tests-semanticdb/src/test/resources/example/Issue1872_2.13.scala b/tests-semanticdb/src/test/resources/example/Issue1872_2.13.scala
new file mode 100644
index 0000000000..43c7d892fc
--- /dev/null
+++ b/tests-semanticdb/src/test/resources/example/Issue1872_2.13.scala
@@ -0,0 +1,13 @@
+package example
+
+object Issue1872/*<=example.Issue1872.*/ {
+
+  val List/*=>scala.package.List.*/(a1_1/*<=example.Issue1872.a1_1.*/) = List/*=>scala.package.List.*/(1)
+
+  val a2_1/*<=example.Issue1872.a2_1.*/, List/*=>scala.package.List.*/(/*a2*/ a2_2/*<=example.Issue1872.a2_2.*/) = List/*=>scala.package.List.*/(1, 2)
+  val b2_1/*<=example.Issue1872.b2_1.*/, List/*=>scala.package.List.*/(/*b2*/ b2_2/*<=example.Issue1872.b2_2.*/: Int/*=>scala.Int#*/) = List/*=>scala.package.List.*/(1, 2)
+  val c2_1/*<=example.Issue1872.c2_1.*/, List/*=>scala.package.List.*/(/*c2*/ c2_2/*<=example.Issue1872.c2_2.*/ @ _) = List/*=>scala.package.List.*/(1, 2)
+
+  val a3_1/*<=example.Issue1872.a3_1.*/, List/*=>scala.package.List.*/(a3_2/*<=example.Issue1872.a3_2.*/, a3_3/*<=example.Issue1872.a3_3.*/) = List/*=>scala.package.List.*/(1, 2, 3)
+
+}
diff --git a/tests-semanticdb/src/test/resources/example/ValPattern.scala b/tests-semanticdb/src/test/resources/example/ValPattern.scala
index cec93065b7..596c98fb2a 100644
--- a/tests-semanticdb/src/test/resources/example/ValPattern.scala
+++ b/tests-semanticdb/src/test/resources/example/ValPattern.scala
@@ -7,7 +7,7 @@ class ValPattern/*<=example.ValPattern#*/ {
     Some/*=>scala.Some.*/(1)
 
   var (leftVar/*<=example.ValPattern#leftVar().*/, rightVar/*<=example.ValPattern#rightVar().*/) = (1, 2)
-  var Some/*=>scala.Some.*/(number1Var/*<=example.ValPattern#number1Var.*/) =
+  var Some/*=>scala.Some.*/(number1Var/*<=example.ValPattern#number1Var().*/) =
     Some/*=>scala.Some.*/(1)
 
   def app/*<=example.ValPattern#app().*/(): Unit/*=>scala.Unit#*/ = {
@@ -23,11 +23,11 @@ class ValPattern/*<=example.ValPattern#*/ {
     )
     locally/*=>scala.Predef.locally().*/ {
       val (left/*<=local6*/, right/*<=local7*/) = (1, 2)
-      val Some/*=>scala.Some.*/(number1/*<=local9*/) =
+      val Some/*=>scala.Some.*/(number1/*<=local10*/) =
         Some/*=>scala.Some.*/(1)
 
       var (leftVar/*<=local11*/, rightVar/*<=local12*/) = (1, 2)
-      var Some/*=>scala.Some.*/(number1Var/*<=local14*/) =
+      var Some/*=>scala.Some.*/(number1Var/*<=local15*/) =
         Some/*=>scala.Some.*/(1)
       println/*=>scala.Predef.println(+1).*/(
         (
diff --git a/tests-semanticdb/src/test/resources/metac-metacp.diff_2.12 b/tests-semanticdb/src/test/resources/metac-metacp.diff_2.12
index 7aac491a3f..5c1ff6d4d8 100644
--- a/tests-semanticdb/src/test/resources/metac-metacp.diff_2.12
+++ b/tests-semanticdb/src/test/resources/metac-metacp.diff_2.12
@@ -596,6 +596,16 @@ example/InstrumentTyper#existential().
                          display_name: "T"
 
 
+======================
+example/Issue1872.x$1.
+======================
+--- metac
++++ metacp
+ access {
+-  public_access {
++  private_this_access {
+
+
 ====================================
 example/Issue2116#check$default$1().
 ====================================
diff --git a/tests-semanticdb/src/test/resources/metac-metacp.diff_2.13 b/tests-semanticdb/src/test/resources/metac-metacp.diff_2.13
index fb7c02aed0..4dcbbf4f2f 100644
--- a/tests-semanticdb/src/test/resources/metac-metacp.diff_2.13
+++ b/tests-semanticdb/src/test/resources/metac-metacp.diff_2.13
@@ -667,6 +667,16 @@ example/InstrumentTyper#existential().
                      display_name: "T"
 
 
+======================
+example/Issue1872.x$1.
+======================
+--- metac
++++ metacp
+ access {
+-  public_access {
++  private_this_access {
+
+
 ====================================
 example/Issue2116#check$default$1().
 ====================================
diff --git a/tests-semanticdb/src/test/resources/metac.expect_2.12 b/tests-semanticdb/src/test/resources/metac.expect_2.12
index cc46bdc4a6..b72b41816b 100644
--- a/tests-semanticdb/src/test/resources/metac.expect_2.12
+++ b/tests-semanticdb/src/test/resources/metac.expect_2.12
@@ -2074,6 +2074,121 @@ Synthetics:
 [14:2..14:5): map => *.update
   update => scala/collection/mutable/MapLike#update().
 
+semanticdb/integration/src/main/scala/example/Issue1872.scala
+-------------------------------------------------------------
+
+Summary:
+Schema => SemanticDB v4
+Uri => semanticdb/integration/src/main/scala/example/Issue1872.scala
+Text => non-empty
+Language => Scala
+Symbols => 18 entries
+Occurrences => 23 entries
+Synthetics => 11 entries
+
+Symbols:
+example/Issue1872. => final object Issue1872 extends AnyRef { +11 decls }
+  AnyRef => scala/AnyRef#
+example/Issue1872.a1_1. => val method a1_1: Int
+  Int => scala/Int#
+example/Issue1872.a2_1. => val method a2_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.a2_2. => val method a2_2: Int
+  Int => scala/Int#
+example/Issue1872.a3_1. => val method a3_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.a3_2. => val method a3_2: Int
+  Int => scala/Int#
+example/Issue1872.a3_3. => val method a3_3: Int
+  Int => scala/Int#
+example/Issue1872.b2_1. => val method b2_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.b2_2. => val method b2_2: Int
+  Int => scala/Int#
+example/Issue1872.c2_1. => val method c2_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.c2_2. => val method c2_2: Int
+  Int => scala/Int#
+example/Issue1872.x$1. => val method x$1: Tuple2[Int, Int]
+  Tuple2 => scala/Tuple2#
+  Int => scala/Int#
+local0 => val local a1_1: Int
+  Int => scala/Int#
+local1 => val local a2_2: Int
+  Int => scala/Int#
+local2 => val local b2_2: Int
+  Int => scala/Int#
+local3 => val local c2_2: Int
+  Int => scala/Int#
+local4 => val local a3_2: Int
+  Int => scala/Int#
+local5 => val local a3_3: Int
+  Int => scala/Int#
+
+Occurrences:
+[0:8..0:15): example <= example/
+[2:7..2:16): Issue1872 <= example/Issue1872.
+[4:6..4:10): List => scala/collection/immutable/List.
+[4:11..4:15): a1_1 <= example/Issue1872.a1_1.
+[4:19..4:23): List => scala/collection/immutable/List.
+[6:6..6:10): a2_1 <= example/Issue1872.a2_1.
+[6:12..6:16): List => scala/collection/immutable/List.
+[6:24..6:28): a2_2 <= example/Issue1872.a2_2.
+[6:32..6:36): List => scala/collection/immutable/List.
+[7:6..7:10): b2_1 <= example/Issue1872.b2_1.
+[7:12..7:16): List => scala/collection/immutable/List.
+[7:24..7:28): b2_2 <= example/Issue1872.b2_2.
+[7:30..7:33): Int => scala/Int#
+[7:37..7:41): List => scala/collection/immutable/List.
+[8:6..8:10): c2_1 <= example/Issue1872.c2_1.
+[8:12..8:16): List => scala/collection/immutable/List.
+[8:24..8:28): c2_2 <= example/Issue1872.c2_2.
+[8:36..8:40): List => scala/collection/immutable/List.
+[10:6..10:10): a3_1 <= example/Issue1872.a3_1.
+[10:12..10:16): List => scala/collection/immutable/List.
+[10:17..10:21): a3_2 <= example/Issue1872.a3_2.
+[10:23..10:27): a3_3 <= example/Issue1872.a3_3.
+[10:31..10:35): List => scala/collection/immutable/List.
+
+Synthetics:
+[4:6..4:10): List => *.unapplySeq[Int]
+  unapplySeq => scala/collection/generic/SeqFactory#unapplySeq().
+  Int => scala/Int#
+[4:19..4:23): List => *.apply[Int]
+  apply => scala/collection/immutable/List.apply().
+  Int => scala/Int#
+[6:12..6:16): List => *.unapplySeq[Int]
+  unapplySeq => scala/collection/generic/SeqFactory#unapplySeq().
+  Int => scala/Int#
+[6:32..6:36): List => *.apply[Int]
+  apply => scala/collection/immutable/List.apply().
+  Int => scala/Int#
+[7:12..7:16): List => *.unapplySeq[Int]
+  unapplySeq => scala/collection/generic/SeqFactory#unapplySeq().
+  Int => scala/Int#
+[7:37..7:41): List => *.apply[Int]
+  apply => scala/collection/immutable/List.apply().
+  Int => scala/Int#
+[8:12..8:16): List => *.unapplySeq[Int]
+  unapplySeq => scala/collection/generic/SeqFactory#unapplySeq().
+  Int => scala/Int#
+[8:36..8:40): List => *.apply[Int]
+  apply => scala/collection/immutable/List.apply().
+  Int => scala/Int#
+[10:12..10:16): List => *.unapplySeq[Int]
+  unapplySeq => scala/collection/generic/SeqFactory#unapplySeq().
+  Int => scala/Int#
+[10:12..10:28): List(a3_2, a3_3) => *.apply[Int, Int]
+  apply => scala/Tuple2.apply().
+  Int => scala/Int#
+[10:31..10:35): List => *.apply[Int]
+  apply => scala/collection/immutable/List.apply().
+  Int => scala/Int#
+
 semanticdb/integration/src/main/scala/example/Issue2040.scala
 -------------------------------------------------------------
 
@@ -5069,7 +5184,7 @@ Occurrences:
 [8:7..8:14): leftVar <= example/ValPattern#leftVar().
 [8:16..8:24): rightVar <= example/ValPattern#rightVar().
 [9:6..9:10): Some => scala/Some.
-[9:11..9:21): number1Var <= example/ValPattern#number1Var.
+[9:11..9:21): number1Var <= example/ValPattern#number1Var().
 [10:4..10:8): Some => scala/Some.
 [12:6..12:9): app <= example/ValPattern#app().
 [12:13..12:17): Unit => scala/Unit#
@@ -5084,12 +5199,12 @@ Occurrences:
 [24:11..24:15): left <= local6
 [24:17..24:22): right <= local7
 [25:10..25:14): Some => scala/Some.
-[25:15..25:22): number1 <= local9
+[25:15..25:22): number1 <= local10
 [26:8..26:12): Some => scala/Some.
 [28:11..28:18): leftVar <= local11
 [28:20..28:28): rightVar <= local12
 [29:10..29:14): Some => scala/Some.
-[29:15..29:25): number1Var <= local14
+[29:15..29:25): number1Var <= local15
 [30:8..30:12): Some => scala/Some.
 [31:6..31:13): println => scala/Predef.println(+1).
 [33:10..33:17): number1 => local9
diff --git a/tests-semanticdb/src/test/resources/metac.expect_2.13 b/tests-semanticdb/src/test/resources/metac.expect_2.13
index e65be14917..02b484270f 100644
--- a/tests-semanticdb/src/test/resources/metac.expect_2.13
+++ b/tests-semanticdb/src/test/resources/metac.expect_2.13
@@ -2179,6 +2179,121 @@ Synthetics:
 [14:2..14:5): map => *.update
   update => scala/collection/mutable/MapOps#update().
 
+semanticdb/integration/src/main/scala/example/Issue1872.scala
+-------------------------------------------------------------
+
+Summary:
+Schema => SemanticDB v4
+Uri => semanticdb/integration/src/main/scala/example/Issue1872.scala
+Text => non-empty
+Language => Scala
+Symbols => 18 entries
+Occurrences => 23 entries
+Synthetics => 11 entries
+
+Symbols:
+example/Issue1872. => final object Issue1872 extends AnyRef { +11 decls }
+  AnyRef => scala/AnyRef#
+example/Issue1872.a1_1. => val method a1_1: Int
+  Int => scala/Int#
+example/Issue1872.a2_1. => val method a2_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.a2_2. => val method a2_2: Int
+  Int => scala/Int#
+example/Issue1872.a3_1. => val method a3_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.a3_2. => val method a3_2: Int
+  Int => scala/Int#
+example/Issue1872.a3_3. => val method a3_3: Int
+  Int => scala/Int#
+example/Issue1872.b2_1. => val method b2_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.b2_2. => val method b2_2: Int
+  Int => scala/Int#
+example/Issue1872.c2_1. => val method c2_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.c2_2. => val method c2_2: Int
+  Int => scala/Int#
+example/Issue1872.x$1. => val method x$1: Tuple2[Int, Int]
+  Tuple2 => scala/Tuple2#
+  Int => scala/Int#
+local0 => val local a1_1: Int
+  Int => scala/Int#
+local1 => val local a2_2: Int
+  Int => scala/Int#
+local2 => val local b2_2: Int
+  Int => scala/Int#
+local3 => val local c2_2: Int
+  Int => scala/Int#
+local4 => val local a3_2: Int
+  Int => scala/Int#
+local5 => val local a3_3: Int
+  Int => scala/Int#
+
+Occurrences:
+[0:8..0:15): example <= example/
+[2:7..2:16): Issue1872 <= example/Issue1872.
+[4:6..4:10): List => scala/package.List.
+[4:11..4:15): a1_1 <= example/Issue1872.a1_1.
+[4:19..4:23): List => scala/package.List.
+[6:6..6:10): a2_1 <= example/Issue1872.a2_1.
+[6:12..6:16): List => scala/package.List.
+[6:24..6:28): a2_2 <= example/Issue1872.a2_2.
+[6:32..6:36): List => scala/package.List.
+[7:6..7:10): b2_1 <= example/Issue1872.b2_1.
+[7:12..7:16): List => scala/package.List.
+[7:24..7:28): b2_2 <= example/Issue1872.b2_2.
+[7:30..7:33): Int => scala/Int#
+[7:37..7:41): List => scala/package.List.
+[8:6..8:10): c2_1 <= example/Issue1872.c2_1.
+[8:12..8:16): List => scala/package.List.
+[8:24..8:28): c2_2 <= example/Issue1872.c2_2.
+[8:36..8:40): List => scala/package.List.
+[10:6..10:10): a3_1 <= example/Issue1872.a3_1.
+[10:12..10:16): List => scala/package.List.
+[10:17..10:21): a3_2 <= example/Issue1872.a3_2.
+[10:23..10:27): a3_3 <= example/Issue1872.a3_3.
+[10:31..10:35): List => scala/package.List.
+
+Synthetics:
+[4:6..4:10): List => *.unapplySeq[Int]
+  unapplySeq => scala/collection/SeqFactory#unapplySeq().
+  Int => scala/Int#
+[4:19..4:23): List => *.apply[Int]
+  apply => scala/collection/IterableFactory#apply().
+  Int => scala/Int#
+[6:12..6:16): List => *.unapplySeq[Int]
+  unapplySeq => scala/collection/SeqFactory#unapplySeq().
+  Int => scala/Int#
+[6:32..6:36): List => *.apply[Int]
+  apply => scala/collection/IterableFactory#apply().
+  Int => scala/Int#
+[7:12..7:16): List => *.unapplySeq[Int]
+  unapplySeq => scala/collection/SeqFactory#unapplySeq().
+  Int => scala/Int#
+[7:37..7:41): List => *.apply[Int]
+  apply => scala/collection/IterableFactory#apply().
+  Int => scala/Int#
+[8:12..8:16): List => *.unapplySeq[Int]
+  unapplySeq => scala/collection/SeqFactory#unapplySeq().
+  Int => scala/Int#
+[8:36..8:40): List => *.apply[Int]
+  apply => scala/collection/IterableFactory#apply().
+  Int => scala/Int#
+[10:12..10:16): List => *.unapplySeq[Int]
+  unapplySeq => scala/collection/SeqFactory#unapplySeq().
+  Int => scala/Int#
+[10:12..10:28): List(a3_2, a3_3) => *.apply[Int, Int]
+  apply => scala/Tuple2.apply().
+  Int => scala/Int#
+[10:31..10:35): List => *.apply[Int]
+  apply => scala/collection/IterableFactory#apply().
+  Int => scala/Int#
+
 semanticdb/integration/src/main/scala/example/Issue2040.scala
 -------------------------------------------------------------
 
@@ -5211,7 +5326,7 @@ Occurrences:
 [8:7..8:14): leftVar <= example/ValPattern#leftVar().
 [8:16..8:24): rightVar <= example/ValPattern#rightVar().
 [9:6..9:10): Some => scala/Some.
-[9:11..9:21): number1Var <= example/ValPattern#number1Var.
+[9:11..9:21): number1Var <= example/ValPattern#number1Var().
 [10:4..10:8): Some => scala/Some.
 [12:6..12:9): app <= example/ValPattern#app().
 [12:13..12:17): Unit => scala/Unit#
@@ -5226,12 +5341,12 @@ Occurrences:
 [24:11..24:15): left <= local6
 [24:17..24:22): right <= local7
 [25:10..25:14): Some => scala/Some.
-[25:15..25:22): number1 <= local9
+[25:15..25:22): number1 <= local10
 [26:8..26:12): Some => scala/Some.
 [28:11..28:18): leftVar <= local11
 [28:20..28:28): rightVar <= local12
 [29:10..29:14): Some => scala/Some.
-[29:15..29:25): number1Var <= local14
+[29:15..29:25): number1Var <= local15
 [30:8..30:12): Some => scala/Some.
 [31:6..31:13): println => scala/Predef.println(+1).
 [33:10..33:17): number1 => local9
diff --git a/tests-semanticdb/src/test/resources/metacp.expect_2.12 b/tests-semanticdb/src/test/resources/metacp.expect_2.12
index df84c48cbd..5f701efe22 100644
--- a/tests-semanticdb/src/test/resources/metacp.expect_2.12
+++ b/tests-semanticdb/src/test/resources/metacp.expect_2.12
@@ -1980,6 +1980,47 @@ example/Issue1854#map. => val method map: Map[String, String]
   Map => scala/collection/mutable/Map#
   String => scala/Predef.String#
 
+example/Issue1872.class
+-----------------------
+
+Summary:
+Schema => SemanticDB v4
+Uri => example/Issue1872.class
+Text => empty
+Language => Scala
+Symbols => 12 entries
+
+Symbols:
+example/Issue1872. => final object Issue1872 extends AnyRef { +11 decls }
+  AnyRef => scala/AnyRef#
+example/Issue1872.a1_1. => val method a1_1: Int
+  Int => scala/Int#
+example/Issue1872.a2_1. => val method a2_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.a2_2. => val method a2_2: Int
+  Int => scala/Int#
+example/Issue1872.a3_1. => val method a3_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.a3_2. => val method a3_2: Int
+  Int => scala/Int#
+example/Issue1872.a3_3. => val method a3_3: Int
+  Int => scala/Int#
+example/Issue1872.b2_1. => val method b2_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.b2_2. => val method b2_2: Int
+  Int => scala/Int#
+example/Issue1872.c2_1. => val method c2_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.c2_2. => val method c2_2: Int
+  Int => scala/Int#
+example/Issue1872.x$1. => private[this] val method x$1: Tuple2[Int, Int]
+  Tuple2 => scala/Tuple2#
+  Int => scala/Int#
+
 example/Issue2040.class
 -----------------------
 
diff --git a/tests-semanticdb/src/test/resources/metacp.expect_2.13 b/tests-semanticdb/src/test/resources/metacp.expect_2.13
index 6917b5f931..40fe605121 100644
--- a/tests-semanticdb/src/test/resources/metacp.expect_2.13
+++ b/tests-semanticdb/src/test/resources/metacp.expect_2.13
@@ -1996,6 +1996,47 @@ example/Issue1854#map. => val method map: Map[String, String]
   Map => scala/collection/mutable/Map#
   String => scala/Predef.String#
 
+example/Issue1872.class
+-----------------------
+
+Summary:
+Schema => SemanticDB v4
+Uri => example/Issue1872.class
+Text => empty
+Language => Scala
+Symbols => 12 entries
+
+Symbols:
+example/Issue1872. => final object Issue1872 extends AnyRef { +11 decls }
+  AnyRef => scala/AnyRef#
+example/Issue1872.a1_1. => val method a1_1: Int
+  Int => scala/Int#
+example/Issue1872.a2_1. => val method a2_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.a2_2. => val method a2_2: Int
+  Int => scala/Int#
+example/Issue1872.a3_1. => val method a3_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.a3_2. => val method a3_2: Int
+  Int => scala/Int#
+example/Issue1872.a3_3. => val method a3_3: Int
+  Int => scala/Int#
+example/Issue1872.b2_1. => val method b2_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.b2_2. => val method b2_2: Int
+  Int => scala/Int#
+example/Issue1872.c2_1. => val method c2_1: List[Int]
+  List => scala/collection/immutable/List#
+  Int => scala/Int#
+example/Issue1872.c2_2. => val method c2_2: Int
+  Int => scala/Int#
+example/Issue1872.x$1. => private[this] val method x$1: Tuple2[Int, Int]
+  Tuple2 => scala/Tuple2#
+  Int => scala/Int#
+
 example/Issue2040.class
 -----------------------