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