From 634fdb023050c6502a841b8f970cb7426a7f6e6e Mon Sep 17 00:00:00 2001 From: Som Snytt Date: Fri, 28 Jun 2024 23:44:59 -0700 Subject: [PATCH] Use final result type to check selector bound --- compiler/src/dotty/tools/dotc/transform/CheckUnused.scala | 2 +- tests/warn/i19657.scala | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala b/compiler/src/dotty/tools/dotc/transform/CheckUnused.scala index 36958397f97f..cec009b12289 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) && selData.qualTpe =:= prefix else // Normal wildcard, check that the symbol is not a given (but can be implicit) diff --git a/tests/warn/i19657.scala b/tests/warn/i19657.scala index cb0e1d3c289d..efd20e36aefb 100644 --- a/tests/warn/i19657.scala +++ b/tests/warn/i19657.scala @@ -30,3 +30,7 @@ def `i19657 check prefix to pick specific selector`: Unit = import FooCodec.given_Schema_A import BarCodec.given_Schema_A summonSchemas + +def `i20860 use result to check selector bound`: Unit = + import Ordering.Implicits.given Ordering[?] + summon[Ordering[Seq[Int]]]