Fix #1812, Symbols.mapSymbols shouldn't replace denotations #1832
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It will use lazy types instead. The current version transforms a type, with
a context that has denotations that may be forcefully replaced by
mapSymbols. Types created during this transformation may cache denots, that
are-to-be replaced. This is very problematic as this method is called from
TreeTypeMap.withMappedSyms in a fixed-point cycle, creating new symbols on
every iteration. Those cached denotations could make types keep symbols
from previous iterations indefinitely.
The changed version does not transform the types eagerly, and instead makes
them lazy. Assuming there are no cycles, this should ensure correct
ordering. Unfortunatelly, at this point in the compiler we basically always
touch everything, and we can't even transform the info of denotation
without this denotations info. We basically have a chicked&egg problem
here. To solve it, I use the same trick as used by other lazy types by
assigning an approximation of future type first. This allows to pass the
tests and makes dotty more robust, but I suspect this isn't a complete fix
and new similar bugs may arrive.