Skip to content

Commit 67ca67c

Browse files
authored
change ValDefs generated from tuples to have proper span
1 parent 4be1482 commit 67ca67c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ object desugar {
11911191
mods & Lazy | Synthetic | (if (ctx.owner.isClass) PrivateLocal else EmptyFlags)
11921192
val firstDef =
11931193
ValDef(tmpName, TypeTree(), matchExpr)
1194-
.withSpan(pat.span.startPos).withMods(patMods)
1194+
.withSpan(pat.span.union(rhs.span)).withMods(patMods)
11951195
val useSelectors = vars.length <= 22
11961196
def selector(n: Int) =
11971197
if useSelectors then Select(Ident(tmpName), nme.selectorName(n))

language-server/test/dotty/tools/languageserver/CompletionTest.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,4 +1441,20 @@ class CompletionTest {
14411441
)
14421442
withProjects(p1, p2).completion(m1, Set(("name", Method, "=> String")))
14431443
}
1444+
1445+
@Test def generatedValDefCompletions: Unit = {
1446+
val expected = ("testMethod", Method, "=> Unit")
1447+
code"""case class Test(x: Int, y: Int)
1448+
|def testMethod: Unit = ???
1449+
|object M:
1450+
| val (x, y) =
1451+
| testMet$m1
1452+
| (1, 2)
1453+
| val Test(x, y) =
1454+
| testMet$m2
1455+
| Test(1, 2)
1456+
"""
1457+
.completion(m1, expected)
1458+
.completion(m2, expected)
1459+
}
14441460
}

0 commit comments

Comments
 (0)