sync new code with usual type arg inference algorithm