Skip to content

[SemanticDB] Missing symbol occurrence on refinement access #14828

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

Open
tanishiking opened this issue Apr 2, 2022 · 0 comments
Open

[SemanticDB] Missing symbol occurrence on refinement access #14828

tanishiking opened this issue Apr 2, 2022 · 0 comments

Comments

@tanishiking
Copy link
Member

tanishiking commented Apr 2, 2022

Compiler version

3.1.1 (#14608)

Minimized code

val a: String = (((1: Any): b.A): Nothing): String
val b: { type A >: Any <: Nothing } = loop()  

Output

sbt> scala3-compiler-bootstrapped/test:runMain dotty.tools.dotc.semanticdb.updateExpect

val a/*<-i5854::B#a.*/: String/*->scala::Predef.String#*/ = (((1: Any/*->scala::Any#*/): b/*->i5854::B#b.*/.A): Nothing/*->scala::Nothing#*/): String/*->scala::Predef.String#*/
val b/*<-i5854::B#b.*/: { type A/*<-local0*/ >: Any/*->scala::Any#*/ <: Nothing/*->scala::Nothing#*/ } = loop/*->i5854::B#loop().*/()

There's no symbol occurrence for b.A on the first line.
see: https://github.com/lampepfl/dotty/blob/ba24fe179c87d1a7a702914aab37e6dd822172c3/tests/semanticdb/expect/i5854.expect.scala

Expectation

val a/*<-i5854::B#a.*/: String/*->scala::Predef.String#*/ = (((1: Any/*->scala::Any#*/): b/*->i5854::B#b.*/.A/*<-local0*/): Nothing/*->scala::Nothing#*/): String/*->scala::Predef.String#*/
val b/*<-i5854::B#b.*/: { type A/*<-local0*/ >: Any/*->scala::Any#*/ <: Nothing/*->scala::Nothing#*/ } = loop/*->i5854::B#loop().*/()

In ExtractSemanticDB, we index the symbols of refinements in a depth first way (type A of b) (because symbols are not attached to the b.A (it only has Name), and then look up the symbol).
However, in the example above, when we try to generate semanticdb symbol, b.A hasn't yet have corresponding symbol in the symbol table. So we fail to retrieve the symbol for b.A.

Possible solutions

  • When we encounter the name symbol which doesn't have the corresponding symbol in the symbol table, generate a fake symbol, and somehow treat it as an alias of the "real symbol" (in this case, the symbol of type A (local0)).
  • As dotty Namer does, index all the symbols to the symbol table first, and then traverse tree again.
@tanishiking tanishiking added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 2, 2022
@tanishiking tanishiking changed the title Missing symbol occurrence on refinement access [SemanticDB] Missing symbol occurrence on refinement access Apr 2, 2022
@KacperFKorban KacperFKorban added area:semanticdb and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Apr 2, 2022
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

2 participants