Skip to content

Commit 799c77f

Browse files
committed
Extract synthetic definitions in a lifted block
1 parent 7fba5a3 commit 799c77f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,14 @@ object ExtractSemanticDB:
286286
|| sym.owner == defn.OpsPackageClass
287287
|| qualifier.exists(excludeQual)
288288

289+
/** This block is created by lifting i.e. EtaExpansion */
290+
private def isProbablyLifted(block: Block)(using Context) =
291+
def isSyntheticDef(t: Tree) =
292+
t match
293+
case t: (ValDef | DefDef) => t.symbol.isSyntheticWithIdent
294+
case _ => false
295+
block.stats.forall(isSyntheticDef)
296+
289297
private def traverseAnnotsOfDefinition(sym: Symbol)(using Context): Unit =
290298
for annot <- sym.annotations do
291299
if annot.tree.span.exists
@@ -438,6 +446,12 @@ object ExtractSemanticDB:
438446
registerUseGuarded(None, sym, tree.span, tree.source)
439447
case _ => ()
440448

449+
// If tree is lifted, ignore Synthetic status on all the definitions and traverse all childrens
450+
case tree: Block if isProbablyLifted(tree) =>
451+
tree.stats.foreach:
452+
case t: (ValDef | DefDef) if !excludeChildren(t.symbol) => traverseChildren(t)
453+
case _ => ()
454+
traverse(tree.expr)
441455

442456
case _ =>
443457
traverseChildren(tree)

0 commit comments

Comments
 (0)