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.
Activity
scabug commentedon 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 commentedon Jan 8, 2014
@dotta said:
scala/scala#3337
scabug commentedon Feb 9, 2014
@adriaanm said:
Ping -- looks like this will go to 2.11.1-RC1?
scabug commentedon 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.
applyDynamicNamed
should have an opaque position #81303 remaining items