Refactor "folding" in resolve for ParamForLoop