private void addForEachConstraint(final ReductionSystem system, final PsiForeachStatement statement) {
    final PsiType paramType = getType(statement.getIterationParameter());
    final PsiExpression value = statement.getIteratedValue();
    if (value != null) {
      final PsiType type = evaluateType(value, system);
      if (type instanceof PsiClassType) {
        final PsiClassType.ClassResolveResult resolveResult = ((PsiClassType)type).resolveGenerics();
        final PsiClass clazz = resolveResult.getElement();
        if (clazz != null) {
          final PsiClass iterableClass =
            JavaPsiFacade.getInstance(clazz.getProject()).findClass("java.lang.Iterable", clazz.getResolveScope());
          if (iterableClass != null) {
            final PsiTypeParameter[] typeParameters = iterableClass.getTypeParameters();
            if (typeParameters.length == 1) {
              final PsiSubstitutor substitutor =
                TypeConversionUtil.getClassSubstitutor(iterableClass, clazz, resolveResult.getSubstitutor());
              if (substitutor != null) {
                final PsiType componentType = substitutor.substitute(typeParameters[0]);
                system.addSubtypeConstraint(componentType, paramType);
              }
            }
          }
        }
      }
      else if (type instanceof PsiArrayType) {
        system.addSubtypeConstraint(((PsiArrayType)type).getComponentType(), paramType);
      }
    }
  }
private void addForEachConstraint(final ReductionSystem system, final PsiForeachStatement statement)