Skip to content

Commit f3f3f23

Browse files
committed
Also catch StaleSymbol in extractSemanticDB
1 parent d38cbde commit f3f3f23

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

compiler/src/dotty/tools/dotc/sbt/ExtractDependencies.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ private class ExtractDependenciesCollector extends tpd.TreeTraverser { thisTreeT
349349
sym.isAnonymousFunction ||
350350
sym.isAnonymousClass
351351
catch case ex: StaleSymbol =>
352+
// can happen for constructor proxies. Test case is pos-macros/i13532.
352353
true
353354

354355

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import Flags._
1313
import Names.Name
1414
import StdNames.nme
1515
import NameOps._
16+
import Denotations.StaleSymbol
1617
import util.Spans.Span
1718
import util.{SourceFile, SourcePosition}
1819
import transform.SymUtils._
@@ -241,8 +242,13 @@ class ExtractSemanticDB extends Phase:
241242
if imported != nme.WILDCARD then
242243
for alt <- tree.expr.tpe.member(imported).alternatives do
243244
registerUseGuarded(None, alt.symbol, sel.imported.span, tree.source)
244-
if (alt.symbol.companionClass.exists)
245-
registerUseGuarded(None, alt.symbol.companionClass, sel.imported.span, tree.source)
245+
try
246+
if (alt.symbol.companionClass.isDefinedInCurrentRun)
247+
registerUseGuarded(None, alt.symbol.companionClass, sel.imported.span, tree.source)
248+
catch case ex: StaleSymbol =>
249+
// can happen for constructor proxies. Test case is pos-macros/i13532.
250+
()
251+
246252
case tree: Inlined =>
247253
traverse(tree.call)
248254
case tree: TypeTree =>

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,8 @@ class Namer { typer: Typer =>
691691
for moduleSym <- companionVals do
692692
if moduleSym.is(Module) && !moduleSym.isDefinedInCurrentRun then
693693
val companion =
694-
if needsConstructorProxies(classSym) then classConstructorCompanion(classSym.asClass)
694+
if needsConstructorProxies(classSym) then
695+
classConstructorCompanion(classSym.asClass)
695696
else newModuleSymbol(
696697
ctx.owner, moduleName, EmptyFlags, EmptyFlags, (_, _) => NoType)
697698
enterSymbol(companion)

0 commit comments

Comments
 (0)