Skip to content

Wrong position assigned to synthetic apply Tree #8125

Open
@scabug

Description

@scabug

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.

Activity

scabug

scabug commented on Jan 8, 2014

@scabug
Author

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

scabug

scabug commented on Jan 8, 2014

@scabug
Author
scabug

scabug commented on Feb 9, 2014

@scabug
Author

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

scabug

scabug commented on Feb 10, 2014

@scabug
Author

@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.

deleted a comment from scabug on Mar 3, 2018
deleted a comment from scabug on Mar 3, 2018

3 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @SethTisue@dotta@scabug

        Issue actions

          Wrong position assigned to synthetic apply Tree · Issue #8125 · scala/bug