public static PsiType getPreferredType(PsiType[] types, PsiType defaultType) {

    if (defaultType instanceof PsiPrimitiveType) return defaultType;

    Map<String, PsiType> map = new HashMap<>();
    for (final PsiType type : types) {
      map.put(serialize(type), type);
    }

    for (StatisticsInfo info : StatisticsManager.getInstance().getAllValues(getStatsKey(defaultType))) {
      final PsiType candidate = map.get(info.getValue());
      if (candidate != null && StatisticsManager.getInstance().getUseCount(info) > 0) {
        return candidate;
      }
    }
    return null;
  }
public static PsiType getPreferredType(PsiType[] types, PsiType defaultType)