Ambiguous implicit found: conflicting given instances in Scala 3 trait inheritance
0 reputation · 30 May 2026, 19:11 UTC
In Scala 3, the compiler emits an Ambiguous implicit found: … error when more than one given satisfies a required type during implicit search. A common scenario is a class that extends two traits, each providing a given for the same type, while the class also declares its own given. The implicit search considers all three instances, but the compiler cannot decide which one to pick, leading to the ambiguity error.
The current language specification does not specify a clear precedence rule for such cases. It is unclear whether locally defined given instances should trump inherited ones, or if the search should favor the most specific trait in the inheritance hierarchy. This lack of a documented hierarchy creates uncertainty for library authors and users who rely on implicit resolution to work predictably.
Given this, the following questions remain open:
- What precedence should the compiler apply when a class inherits multiple
giveninstances for the same type and also defines its owngiven? - Is there an intended resolution strategy that will be adopted in future Scala 3 releases?
- How can developers write trait hierarchies that avoid this ambiguity without relying on compiler-specific workarounds?