-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Currently, Annotations.refersToParamOf
assumes that all TermParamRef
types will only appear as the (root) type of Ident
or This
trees:
scala3/compiler/src/dotty/tools/dotc/core/Annotations.scala
Lines 75 to 82 in 912b6f2
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.