// We visit the iterator before the loop variable because the loop variable cannot be in scope
// while visiting the iterator.
//
Expression iterator = node.getIterator();
safelyVisit(iterator);
DeclaredIdentifier loopVariable = node.getLoopVariable();
SimpleIdentifier identifier = node.getIdentifier();
safelyVisit(loopVariable);
safelyVisit(identifier);
Statement body = node.getBody();
if (body != null) {
overrideManager.enterScope();
try {
if (loopVariable != null && iterator != null) {
LocalVariableElement loopElement = loopVariable.getElement();
if (loopElement != null) {
Type iteratorElementType = getIteratorElementType(iterator);
overrideVariable(loopElement, iteratorElementType, true);
recordPropagatedType(loopVariable.getIdentifier(), iteratorElementType);
}
} else if (identifier != null && iterator != null) {
Element identifierElement = identifier.getStaticElement();
if (identifierElement instanceof VariableElement) {
Type iteratorElementType = getIteratorElementType(iterator);