Skip to content

IDE: Cannot navigate from left operand of a right-associative infix op #4498

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

Closed
odersky opened this issue May 10, 2018 · 2 comments
Closed
Assignees

Comments

@odersky
Copy link
Contributor

odersky commented May 10, 2018

In dotc.Compiler, try to navigate from the phases list to the individual phases. E.g. goto definition on "ElimRepeated" gives "no definition found". However, if I copy the ElimRepeated identifier outside the list, navigation works as expected.

@odersky
Copy link
Contributor Author

odersky commented May 10, 2018

Correction: The fault seems to lie with infix operators, not varargs.

If I just write new ElimRepeated, it finds it. But if I write new ElimRepeated :: Nil, I can't hyperlink on ElimRepeated.

@odersky odersky changed the title IDE: Cannot navigate from variable parameters(?) IDE: Cannot navigate from left operand of a right-associative infix op May 10, 2018
@odersky
Copy link
Contributor Author

odersky commented May 10, 2018

Nil :+ new ElimRepeated also works. So the fault seems to lie with left operands of right-associative infix operators like ::.

Duhemm added a commit to dotty-staging/dotty that referenced this issue May 11, 2018
Consider the following snippet:

```
val lst = new A :: Nil
```

This is rewritten as:

```
val lst = {
  val x$0 = new A
  Nil.::(x$0)
}
```

During lifting, we need to assign positions to the trees. We were
assigning the position of `new A` in the original code to `x$0` in
`Nil.::(x$0)`, and the original position of `new A` to `val x$0 = new A`
with a zero-extent.

Still considering this snippet, this means that when trying to go to the
definition on `new A`, the IDE would think that the user tried to go to
the definition of `x$0`, because the IDE would look for the matching
tree by position.

This commit changes this so that the lifted definition
(`val x$0 = new A`) gets the position of the original expression, and
the reference gets a synthetic, zero-extent position. With this change,
the IDE correctly finds the right tree when selecting `new A` in the
original code.

Fixes scala#4498
odersky added a commit that referenced this issue May 11, 2018
Fix #4498: Go to definition in lifted expressions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants