private PsiType getTypeToUseByList(GrListOrMap listOrMap, PsiType type) {
    if (isImplicitlyCastedToArray(listOrMap)) {
      PsiType iterable = ClosureParameterEnhancer.findTypeForIteration(listOrMap, listOrMap);
      if (iterable != null) {
        return new PsiArrayType(iterable);
      }
    }
    else if (expectedType instanceof PsiArrayType) {
      return expectedType;
    }
    if (type instanceof PsiClassType) {
      PsiClass resolved = ((PsiClassType)type).resolve();
      if (resolved != null && CommonClassNames.JAVA_UTIL_LIST.equals(resolved.getQualifiedName())) {
        JavaPsiFacade facade = JavaPsiFacade.getInstance(listOrMap.getProject());
        PsiClass arrayList = facade.findClass(CommonClassNames.JAVA_UTIL_ARRAY_LIST, listOrMap.getResolveScope());
        if (arrayList != null) {
          return facade.getElementFactory().createType(arrayList, ((PsiClassType)type).getParameters());
        }
      }
    }
    return type;
  }
private PsiType getTypeToUseByList(GrListOrMap listOrMap, PsiType type)