diff --git a/compiler/src/dotty/tools/dotc/core/TypeOps.scala b/compiler/src/dotty/tools/dotc/core/TypeOps.scala index d12ecd8cd17f..ab06809f29bc 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeOps.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeOps.scala @@ -512,7 +512,7 @@ object TypeOps: @threadUnsafe lazy val forbidden = symsToAvoid.toSet def toAvoid(tp: NamedType) = val sym = tp.symbol - !sym.isStatic && forbidden.contains(sym) + forbidden.contains(sym) override def apply(tp: Type): Type = tp match case tp: TypeVar if mapCtx.typerState.constraint.contains(tp) => diff --git a/tests/pos/i9314.scala b/tests/pos/i9314.scala new file mode 100644 index 000000000000..94aa0adaeb46 --- /dev/null +++ b/tests/pos/i9314.scala @@ -0,0 +1,4 @@ +final class fooAnnot[T](member: T) extends scala.annotation.StaticAnnotation // must have type parameter + +@fooAnnot(new RecAnnotated {}) // must pass instance of anonymous subclass +trait RecAnnotated