Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b3bb4ef

Browse files
committedMar 3, 2025·
Add a comment explaining the stale symbol fix
1 parent 09f13d5 commit b3bb4ef

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed
 

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

+6
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,12 @@ class Namer { typer: Typer =>
712712
enterSymbol(classConstructorCompanion(classSym.asClass))
713713
else
714714
for moduleSym <- companionVals do
715+
// by not going throught `.lastKnownDenotation` (instead using `.current`),
716+
// we guarantee that the `moduleSym` will be brought forward to the current run,
717+
// rendering isDefinedInCurrentRun as always true
718+
// We want to possibly regenerate the companion instead of bringing it forward,
719+
// as even if we are able to bring forward the object symbol,
720+
// we might not be able to do the same with its stale module class symbol (see `tests/pos/i20449`)
715721
if moduleSym.lastKnownDenotation.is(Module) && !moduleSym.isDefinedInCurrentRun then
716722
val companion =
717723
if needsConstructorProxies(classSym) then

0 commit comments

Comments
 (0)
Please sign in to comment.