Fix resolve to not permit refs to type vars from outer fns
(Fixes #14603)