Do not update Symbol defTrees when retyping after Inlining #23870
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.
Fixes #21176
The scaladoc for the
defTree
method inSymbols.scala
states: "The tree defining the symbol at pickler time ...", but that was never really true.Previously, since the
setDefTree
method was used in Typer, in any retyping procedure those methods would be called again, with the main example being erasure, where we would lose parts of type information from those trees. Usually this was not an issue, since they weren't used after Erasure.However, the suspend mechanism used when compiling macros with calls to them can cause the macro tree to go through
erasure, have their defTrees updated there and then used for earlier phases, with the problematic phase here being the init-checker, which uses defTree calls extensively.
In the issue minimisation, init-checker was expecting a
MethodType
(due to the missing TypeApply there after erasure), and instead got aPolyType
, causing a crash.Coincidentally in the past we would sometimes also get issues about
.tree
method in Quotes returning unexpected stuff due to the same issue, so this should also help there (this is why the test case for #22584 was changed, val symbol returning a ValDef makes more sense anyway).In the first commit we also reset the TyperState after suspension, to avoid any unfulfilled constraints raised in Ycheck, as mentioned in the same issue ticket (although the causes ended up being separate) .