diff --git a/compiler/src/dotty/tools/dotc/core/Annotations.scala b/compiler/src/dotty/tools/dotc/core/Annotations.scala index d6a99b12e3b3..d7f50d4638ab 100644 --- a/compiler/src/dotty/tools/dotc/core/Annotations.scala +++ b/compiler/src/dotty/tools/dotc/core/Annotations.scala @@ -73,7 +73,7 @@ object Annotations { /** Does this annotation refer to a parameter of `tl`? */ def refersToParamOf(tl: TermLambda)(using Context): Boolean = - val args = arguments + val args = tpd.allArguments(tree) if args.isEmpty then false else tree.existsSubTree: case id: (Ident | This) => id.tpe.stripped match diff --git a/tests/pos/dependent-annot-type-param.scala b/tests/pos/dependent-annot-type-param.scala new file mode 100644 index 000000000000..174e9f78fba6 --- /dev/null +++ b/tests/pos/dependent-annot-type-param.scala @@ -0,0 +1,5 @@ +class annot[T] extends annotation.Annotation +class Box[T]() +def f(x: Int): Int @annot[Box[x.type]] = x +def test = + val foo = f(42)