From bc207ad2d037d63eae11c8f234a4b8ef59251cc5 Mon Sep 17 00:00:00 2001 From: Kacper Korban Date: Wed, 6 Jul 2022 20:25:35 +0200 Subject: [PATCH] Remove isStatic check from TypeOps.avoid fixes #9314 --- compiler/src/dotty/tools/dotc/core/TypeOps.scala | 2 +- tests/pos/i9314.scala | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i9314.scala 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