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