Skip to content

Fix #5583: Pass correct offset to bind node #5705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1699,8 +1699,8 @@ object Parsers {
case pt @ Ident(tpnme.WILDCARD_STAR) =>
migrationWarningOrError("The syntax `x @ _*' is no longer supported; use `x : _*' instead", startOffset(p))
atPos(startOffset(p), offset) { Typed(p, pt) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The offset in the above looks dubious too

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the positions of those trees and they look fine.

case p =>
atPos(startOffset(p), offset) { Bind(name, p) }
case pt =>
atPos(startOffset(p), 0) { Bind(name, pt) }
}
case p @ Ident(tpnme.WILDCARD_STAR) =>
// compatibility for Scala2 `_*` syntax
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,27 @@ class DefinitionTest {
.definition(m15 to m16, List(m7 to m8))
}

@Test def goToBinding: Unit = {
withSources(
code"""class Foo {
|val x = Some(6)
|x match {
| case ${m1}x${m2} @ Some(_) => ${m3}x${m4}
|}
|x match {
| case ${m5}xyz${m6} @ None => ${m7}xyz${m8}
|}
|val y: Any = ???
|y match {
| case ${m9}a${m10} @ Some(${m11}bb${m12} @ Some(${m13}ccc${m14})) =>
| ${m15}a${m16}
| ${m17}bb${m18}
| ${m19}ccc${m20}
|}"""
) .definition(m3 to m4, List(m1 to m2))
.definition(m7 to m8, List(m5 to m6))
.definition(m15 to m16, List(m9 to m10))
.definition(m17 to m18, List(m11 to m12))
.definition(m19 to m20, List(m13 to m14))
}
}