Scala 3 ambiguous given resolution for using parameters
0 reputation · 04 Apr 2025, 02:31 UTC
Symptom
A Scala 3 method declares a context parameter with a using clause, and more than one eligible given instance is visible through local definitions, imports, or the implicit scope of the expected type. The compiler reports ambiguous implicit values instead of selecting one instance.
Goal and constraints
The goal is to diagnose which candidate givens the compiler is considering and why no single instance wins. Resolution behavior can differ by Scala 3 minor version, so the applicable implicit search rules depend on the project's scalaVersion. The compiler does not defer this choice to runtime, and subtype specificity alone does not always disambiguate without explicit priority annotations.
Specific questions:
- Which Scala 3 minor version's implicit search rules govern this compilation unit?
- Do imported givens and companion-object givens participate equally in the candidate set?
- Is an explicit given priority or narrowed import required to make one instance unambiguous?