From 21dad7712fdf7359fe183135cbc58284ea71e300 Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Wed, 3 Jul 2024 04:42:33 -0700 Subject: [PATCH] Use final result type to check selector bound --- compiler/src/dotty/tools/dotc/transform/CheckUnused.scala | 2 +- tests/pos/i20860.scala | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i20860.scala diff --git a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala index d8389ff964a4..d396d60c096a 100644 --- a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala +++ b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala @@ -729,7 +729,7 @@ object CheckUnused: if selector.isGiven then // Further check that the symbol is a given or implicit and conforms to the bound sym.isOneOf(Given | Implicit) - && (selector.bound.isEmpty || sym.info <:< selector.boundTpe) + && (selector.bound.isEmpty || sym.info.finalResultType <:< selector.boundTpe) else // Normal wildcard, check that the symbol is not a given (but can be implicit) !sym.is(Given) diff --git a/tests/pos/i20860.scala b/tests/pos/i20860.scala new file mode 100644 index 000000000000..1e1ddea11b75 --- /dev/null +++ b/tests/pos/i20860.scala @@ -0,0 +1,3 @@ +def `i20860 use result to check selector bound`: Unit = + import Ordering.Implicits.given Ordering[?] + summon[Ordering[Seq[Int]]]