scala3 icon indicating copy to clipboard operation
scala3 copied to clipboard

Fix `Annotation.refersToParamOf` to work with parameter references outside of `Ident` or `This`

Open mbovel opened this issue 1 year ago • 1 comments

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: refersToParamOf should visit the least possible number of trees and types.

mbovel avatar Nov 22 '24 12:11 mbovel