diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index cff9407e9328..af2ba5019d0b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -158,7 +158,8 @@ class Typer extends Namer */ def qualifies(denot: Denotation): Boolean = reallyExists(denot) - && !(pt.isInstanceOf[UnapplySelectionProto] && denot.symbol.is(Method, butNot = Accessor)) + && (!pt.isInstanceOf[UnapplySelectionProto] + || denot.hasAltWith(sd => !sd.symbol.is(Method, butNot = Accessor))) && !denot.symbol.is(PackageClass) /** Find the denotation of enclosing `name` in given context `ctx`. diff --git a/tests/pos/i11421.scala b/tests/pos/i11421.scala new file mode 100644 index 000000000000..6d4cf618bffc --- /dev/null +++ b/tests/pos/i11421.scala @@ -0,0 +1,9 @@ +class Foo { + def ::(hd: String): Foo = ??? + def ::(hd: Boolean): Foo = ??? + + List(1, 2) match { + case x :: tail => () + case _ => () + } +} \ No newline at end of file