Skip to content

Commit 615fdc9

Browse files
Merge pull request #5705 from dotty-staging/fix-#5583
Fix #5583: Pass correct offset to bind node
2 parents 6e39ebc + c5326ca commit 615fdc9

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,8 +1699,8 @@ object Parsers {
16991699
case pt @ Ident(tpnme.WILDCARD_STAR) =>
17001700
migrationWarningOrError("The syntax `x @ _*' is no longer supported; use `x : _*' instead", startOffset(p))
17011701
atPos(startOffset(p), offset) { Typed(p, pt) }
1702-
case p =>
1703-
atPos(startOffset(p), offset) { Bind(name, p) }
1702+
case pt =>
1703+
atPos(startOffset(p), 0) { Bind(name, pt) }
17041704
}
17051705
case p @ Ident(tpnme.WILDCARD_STAR) =>
17061706
// compatibility for Scala2 `_*` syntax

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,4 +344,27 @@ class DefinitionTest {
344344
.definition(m15 to m16, List(m7 to m8))
345345
}
346346

347+
@Test def goToBinding: Unit = {
348+
withSources(
349+
code"""class Foo {
350+
|val x = Some(6)
351+
|x match {
352+
| case ${m1}x${m2} @ Some(_) => ${m3}x${m4}
353+
|}
354+
|x match {
355+
| case ${m5}xyz${m6} @ None => ${m7}xyz${m8}
356+
|}
357+
|val y: Any = ???
358+
|y match {
359+
| case ${m9}a${m10} @ Some(${m11}bb${m12} @ Some(${m13}ccc${m14})) =>
360+
| ${m15}a${m16}
361+
| ${m17}bb${m18}
362+
| ${m19}ccc${m20}
363+
|}"""
364+
) .definition(m3 to m4, List(m1 to m2))
365+
.definition(m7 to m8, List(m5 to m6))
366+
.definition(m15 to m16, List(m9 to m10))
367+
.definition(m17 to m18, List(m11 to m12))
368+
.definition(m19 to m20, List(m13 to m14))
369+
}
347370
}

0 commit comments

Comments
 (0)