Skip to content

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

Open
@mbovel

Description

@mbovel

Currently, Annotations.refersToParamOf assumes that all TermParamRef types will only appear as the (root) type of Ident or This trees:

def refersToParamOf(tl: TermLambda)(using Context): Boolean =
val args = arguments
if args.isEmpty then false
else tree.existsSubTree:
case id: (Ident | This) => id.tpe.stripped match
case TermParamRef(tl1, _) => tl eq tl1
case _ => false
case _ => false

This assumption can be invalidated, for example when trees are generated by macros.

See #22001 (comment) 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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions