Skip to content
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

Wrong position assigned to synthetic apply Tree #8125

Open
scabug opened this issue Jan 8, 2014 · 4 comments
Open

Wrong position assigned to synthetic apply Tree #8125

scabug opened this issue Jan 8, 2014 · 4 comments

Comments

@scabug
Copy link

scabug commented Jan 8, 2014

I'm looking at a completion issue in the IDE that is due to a Tree having a transparent position, when an opaque one is expected.

I'll use the following code for describing the issue:

object A {
  def apply(a: Int) = a
  A(
}

Notice the missing closing parens, so there is a syntax error. Nonetheless, if you explicitly type A.apply(, completion works as expected (hence,
I expect this should work similarly when the synthetic apply is injected by scalac).

I had a look at the tree, and my belief is that the positions assigned when expanding A(null) (this is the Tree after parser) into A.apply(null)
(this is the tree I see in typer, while debugging) are incorrect, because the qualifier A in the latter Tree ( A.apply(null)) has a transparent position,
instead of an opaque one. The fact that the qualifier has a transparent position messes up completion, as we need to retrieve the qualifier to look at its members.

Jason correctly suggested to look into insertApply in Typers, and specifically this expression:

       typedPos(tree.pos, mode, pt) {
          Select(qual setPos tree.pos.makeTransparent, nme.apply)
       }

Indeed, changing the above into

       typedPos(tree.pos.makeTransparent, mode, pt) {
          Select(qual setPos tree.pos, nme.apply)
       }

fixes the issue. Will issue a PR soon.

@scabug
Copy link
Author

scabug commented Jan 8, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8125?orig=1
Reporter: @dotta
Affected Versions: 2.11.0-M7
See #5064, #8136

@scabug
Copy link
Author

scabug commented Jan 8, 2014

@dotta said:
scala/scala#3337

@scabug
Copy link
Author

scabug commented Feb 9, 2014

@adriaanm said:
Ping -- looks like this will go to 2.11.1-RC1?

@scabug
Copy link
Author

scabug commented Feb 10, 2014

@dotta said:
Indeed, if not even later - not sure when and if I'll have time to work on this. The PR I linked should be a very good starting point for anyone willing to have a look at this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants