From 63dc305126bf57af6328afeb5f43e596decb6fcb Mon Sep 17 00:00:00 2001 From: Matt Bovel Date: Thu, 21 Nov 2024 21:10:31 +0100 Subject: [PATCH] Consider all arguments in Annotations.refersToParamOf --- compiler/src/dotty/tools/dotc/core/Annotations.scala | 2 +- tests/pos/dependent-annot-type-param.scala | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/pos/dependent-annot-type-param.scala 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)