Skip to content

Commit 504574d

Browse files
jchybtgodzik
authored andcommitted
Add a comment explaining the stale symbol fix
[Cherry-picked 23911df]
1 parent dd92432 commit 504574d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,12 @@ class Namer { typer: Typer =>
694694
enterSymbol(classConstructorCompanion(classSym.asClass))
695695
else
696696
for moduleSym <- companionVals do
697+
// by not going through `.lastKnownDenotation` (instead using `.current`),
698+
// we guarantee that the `moduleSym` will be brought forward to the current run,
699+
// rendering `moduleSym.isDefinedInCurrentRun` as always true.
700+
// We want to regenerate the companion instead of bringing it forward,
701+
// as even if we are able to bring forward the object symbol,
702+
// we might not be able to do the same with its stale module class symbol (see `tests/pos/i20449`)
697703
if moduleSym.lastKnownDenotation.is(Module) && !moduleSym.isDefinedInCurrentRun then
698704
val companion =
699705
if needsConstructorProxies(classSym) then

0 commit comments

Comments
 (0)