scala3
scala3 copied to clipboard
Fix `Annotation.refersToParamOf` to work with parameter references outside of `Ident` or `This`
Currently, Annotations.refersToParamOf assumes that all TermParamRef types will only appear as the (root) type of Ident or This trees:
https://github.com/scala/scala3/blob/912b6f278b0fe5e7a25160612922cadf184acdbb/compiler/src/dotty/tools/dotc/core/Annotations.scala#L75-L82
This assumption can be invalidated, for example when trees are generated by macros.
See https://github.com/scala/scala3/pull/22001#discussion_r1853054112 for prior discussion. I proposed two fixes there.
To do:
- [ ] write test-cases,
- [ ] find the minimal fix:
refersToParamOfshould visit the least possible number of trees and types.