Fix for macro annotation that resolves macro-based implicit crashing the compiler #20353
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.
When (1) macro-annotating a class or object nested in another class or object and (2) the annotation macro tries to summon an implicit value using
Implicits.search
and (3) the implicit search needs to expand agiven
macro, the compiler crashes with:I found that the reason for the crash is
macroDependencies
returning locally defined variables, which, I believe, it should not. In particular it returns a list containing$anonfun
for trees of the following shape that appear when resolving implicit macros:This PR skips over such
Closure
nodes, which should be the correct behavior. Not sure if there are other cases thatmacroDependencies
handles incorrectly and that should be fixed ...