E205: Given Search Priority Warning

This warning occurs when the implicit search algorithm would select a different given instance under Scala 3.7 rules compared to Scala 3.6 rules. This is a migration warning to alert users about behavior changes in given instance resolution.

In Scala 3.7, the given search priority rules have been refined. When multiple given instances are available for the same type, the selection algorithm may choose differently than it did in Scala 3.6, particularly regarding how type specificity is evaluated.

Example

//> using options -source:3.6

trait A
trait B extends A
given b: B = ???
given a: A = ???

def example = summon[A]

Error

-- [E205] Potential Issue Warning: example.scala:8:23 --------------------------
8 |def example = summon[A]
  |                       ^
  |            Given search preference for A between alternatives
  |              (b : B)
  |            and
  |              (a : A)
  |            will change in the future release.
  |            Current choice        : the first alternative
  |            Choice from Scala 3.7 : the second alternative
  |
  |            Suppress this warning by choosing -source 3.5, -source 3.7, or
  |            by using @annotation.nowarn("id=205")

Solution

Explicitly reference the desired given instance to avoid ambiguity:

//> using options -source:3.6

trait A
trait B extends A
given b: B = ???
given a: A = ???

def example: A = a

Alternatively, you can suppress the warning by:

  • Using -source 3.5 to keep the old behavior
  • Using -source 3.7 to use the new behavior
  • Adding @annotation.nowarn("id=205") to suppress the warning locally