Which Scala 3 using binding wins across compilation units
0 reputation · 28 Jun 2026, 16:21 UTC
Understanding implicit priority for Scala 3 using parameters when the bindings live in different source files. The using keyword introduces implicit parameters that are passed automatically, and resolution is described as nearest-scope first. The uncertainty is how nearest scope is defined across compilation units.
When multiple using groups for the same type exist in separate files, and one is imported into a file that also defines a local using, the intended precedence is not clear from the design description alone. Cross-compilation scenarios with Scala 2 implicits add further ambiguity, and the compiler warning for a shadowed using group suggests runtime differences can depend on how the binding is selected.
Does Scala 3 apply nearest-scope priority strictly within a single compilation unit, or does import proximity across files influence selection? Which rule determines the winner when a using binding is defined in an enclosing class versus an imported using group from another compilation unit?