[Chapel Merge] Fix memory leak in reduceLoopOfPromoted.chpl

Branch: refs/heads/master
Revision: 837c3f3
Author: vasslitvinov
Log Message:

Merge pull request #16691 from vasslitvinov/no-leak-reduceLoopOfPromoted

Fix memory leak in reduceLoopOfPromoted.chpl

Resolves https://github.com/Cray/chapel-private/issues/1392
Fixes memory leak in test/reductions/reduceLoopOfPromoted.chpl

This applies the solution for avoiding memory leaks, discovered in #16518
for the then-added chpl_elemTypeForReducingIterables(), to iteratorIndexType().
Moves the explanatory comments there as well.

While there, splits a couple of long lines, which I was supposed
to do in #16518.

Does not affect other known memory leaks.

Future work: apply the same solution to iteratorIndex() itself.
For that, it needs to be passed the iterator itself
rather than an iterator class (as it is done now).

r: @e-kayrakli

Modified Files:
M modules/internal/ChapelIteratorSupport.chpl

Compare: https://github.com/chapel-lang/chapel/compare/5e8010047318...837c3f3de173