diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index a5c582fecd5d..51bb126c4295 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -1129,7 +1129,7 @@ trait Checking { val preExisting = ctx.effectiveScope.lookup(ename) if (preExisting.exists || seen.contains(ename)) ctx.error(em"@alpha annotation ${'"'}$ename${'"'} clashes with other definition is same scope", stat.sourcePos) - seen += ename + if stat.isDef then seen += ename } } } diff --git a/tests/pos/i8391.scala b/tests/pos/i8391.scala new file mode 100644 index 000000000000..d0e40ecda39f --- /dev/null +++ b/tests/pos/i8391.scala @@ -0,0 +1,13 @@ +import scala.annotation.alpha + +trait Foo { + @alpha("intersection") + def *(other: Foo): Foo +} + +@main def Test() = { + val s: Foo = ??? + s * s + s * s + s * s +}