Ok, that makes sense, although not ideal because it means that solver would produce potentially invalid solution(s) if something can't be synthesized. Regardless of that, I think a good strategy here would be to
modify matchCallArguments
to replace Bar
with its opened callAsFunction
requirement if the argument is a closure (I have added TypeVariable::Implementation::isClosureType()
for that) and record that such conversion has happened, every other parameter requirement has to be ignored. That way when solution is formed it would have necessary information for rewriting to happen.