Static type analysis with dynamic scoping?
There is a paper titled Implicit Parameters: Dynamic Scoping with Static Types that discusses just such a system.

The implement a slightly different system from Scala under the name "implicit parameters". By having compiler automatically generate implicit parameters in any function that calls other functions with implicit parameters the problem becomes nearly identical to standard type inference. Additionally, since these implicit parameters are still part of each functions type signature they propose a syntax for declaring most of a functions signature, while still allowing the compiler to determine the types of any implicit parameters.