From 3d67ee49957e42f94ed306f87c4b4183429b173d Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 16 Feb 2021 10:18:25 +0100 Subject: [PATCH] Skip overloaded methods when looking for an extractor The previous logic only skipped non-overloaded methods. Fixes #11421 --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 3 ++- tests/pos/i11421.scala | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i11421.scala 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