Also fix type inference for functions with mandatory keyword arguments in other cases. Related to PR 12434. original commit: eb387837505c29064978202136a9284aae63d308