Skip to content

Commit b30dae6

Browse files
committed
Fix missing symbol occurrence for typebounds of type params
1 parent dd358f9 commit b30dae6

File tree

3 files changed

+3018
-70
lines changed

3 files changed

+3018
-70
lines changed

compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,39 @@ class ExtractSemanticDB extends Phase:
174174
registerUseGuarded(None, privateWithin, spanOfSymbol(privateWithin, tree.span, tree.source), tree.source)
175175
else if !excludeSymbol(tree.symbol) then
176176
registerSymbol(tree.symbol, symbolKinds(tree))
177+
tree match
178+
case tree: ValDef
179+
if tree.symbol.isAllOf(EnumValue) =>
180+
tree.rhs match
181+
case Block(TypeDef(_, template: Template) :: _, _) => // simple case with specialised extends clause
182+
template.parents.filter(!_.span.isZeroExtent).foreach(traverse)
183+
case _ => // calls $new
184+
case tree: ValDef
185+
if tree.symbol.isSelfSym =>
186+
if tree.tpt.span.hasLength then
187+
traverse(tree.tpt)
188+
case tree: DefDef
189+
if tree.symbol.isConstructor => // ignore typeparams for secondary ctors
190+
tree.trailingParamss.foreach(_.foreach(traverse))
191+
traverse(tree.rhs)
192+
case tree: (DefDef | ValDef)
193+
if tree.symbol.isSyntheticWithIdent =>
194+
tree match
195+
case tree: DefDef =>
196+
tree.paramss.foreach(_.foreach(param => registerSymbolSimple(param.symbol)))
197+
case tree: ValDef if tree.symbol.is(Given) => traverse(tree.tpt)
198+
case _ =>
199+
if !tree.symbol.isGlobal then
200+
localBodies(tree.symbol) = tree.rhs
201+
// ignore rhs
202+
case PatternValDef(pat, rhs) =>
203+
traverse(rhs)
204+
PatternValDef.collectPats(pat).foreach(traverse)
205+
case tree: TypeDef =>
206+
traverseChildren(tree)
207+
case tree =>
208+
if !excludeChildren(tree.symbol) then
209+
traverseChildren(tree)
177210
case tree: Template =>
178211
val ctorSym = tree.constr.symbol
179212
if !excludeDef(ctorSym) then

tests/semanticdb/expect/i9782.expect.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ trait Elem/*<-_empty_::Elem#*/[T/*<-_empty_::Elem#[T]*/ <: Txn/*->_empty_::Txn#*
66
trait Obj/*<-_empty_::Obj#*/[T/*<-_empty_::Obj#[T]*/ <: Txn/*->_empty_::Txn#*/[T/*->_empty_::Obj#[T]*/]] extends Elem/*->_empty_::Elem#*/[T/*->_empty_::Obj#[T]*/]
77

88
trait Copy/*<-_empty_::Copy#*/[In/*<-_empty_::Copy#[In]*/ <: Txn/*->_empty_::Txn#*/[In/*->_empty_::Copy#[In]*/], Out/*<-_empty_::Copy#[Out]*/ <: Txn/*->_empty_::Txn#*/[Out/*->_empty_::Copy#[Out]*/]] {
9-
def copyImpl/*<-_empty_::Copy#copyImpl().*/[Repr/*<-_empty_::Copy#copyImpl().[Repr]*/[~ <: Txn[~]] <: Elem[~]](in/*<-_empty_::Copy#copyImpl().(in)*/: Repr/*->_empty_::Copy#copyImpl().[Repr]*/[In/*->_empty_::Copy#[In]*/]): Repr/*->_empty_::Copy#copyImpl().[Repr]*/[Out/*->_empty_::Copy#[Out]*/]
9+
def copyImpl/*<-_empty_::Copy#copyImpl().*/[Repr/*<-_empty_::Copy#copyImpl().[Repr]*/[~/*<-_empty_::Copy#copyImpl().[Repr][`~`]*/ <: Txn/*->_empty_::Txn#*/[~/*->_empty_::Copy#copyImpl().[Repr][`~`]*/]] <: Elem/*->_empty_::Elem#*/[~/*->_empty_::Copy#copyImpl().[Repr][`~`]*/]](in/*<-_empty_::Copy#copyImpl().(in)*/: Repr/*->_empty_::Copy#copyImpl().[Repr]*/[In/*->_empty_::Copy#[In]*/]): Repr/*->_empty_::Copy#copyImpl().[Repr]*/[Out/*->_empty_::Copy#[Out]*/]
1010

11-
def apply/*<-_empty_::Copy#apply().*/[Repr/*<-_empty_::Copy#apply().[Repr]*/[~ <: Txn[~]] <: Elem[~]](in/*<-_empty_::Copy#apply().(in)*/: Repr/*->_empty_::Copy#apply().[Repr]*/[In/*->_empty_::Copy#[In]*/]): Repr/*->_empty_::Copy#apply().[Repr]*/[Out/*->_empty_::Copy#[Out]*/] = {
11+
def apply/*<-_empty_::Copy#apply().*/[Repr/*<-_empty_::Copy#apply().[Repr]*/[~/*<-_empty_::Copy#apply().[Repr][`~`]*/ <: Txn/*->_empty_::Txn#*/[~/*->_empty_::Copy#apply().[Repr][`~`]*/]] <: Elem/*->_empty_::Elem#*/[~/*->_empty_::Copy#apply().[Repr][`~`]*/]](in/*<-_empty_::Copy#apply().(in)*/: Repr/*->_empty_::Copy#apply().[Repr]*/[In/*->_empty_::Copy#[In]*/]): Repr/*->_empty_::Copy#apply().[Repr]*/[Out/*->_empty_::Copy#[Out]*/] = {
1212
val out/*<-local0*/ = copyImpl/*->_empty_::Copy#copyImpl().*/[Repr/*->_empty_::Copy#apply().[Repr]*/](in/*->_empty_::Copy#apply().(in)*/)
1313
(in/*->_empty_::Copy#apply().(in)*/, out/*->local0*/) match {
1414
case (inObj/*<-local1*/: Obj/*->_empty_::Obj#*/[In/*->_empty_::Copy#[In]*/], outObj/*<-local2*/: Obj/*->_empty_::Obj#*/[Out/*->_empty_::Copy#[Out]*/]) => // problem here

0 commit comments

Comments
 (0)