Correctly infer phantom type parameter even when arguments come from different scopes