@NotNull
  public static PsiType getExactlyPromotedType(@NotNull PsiElement context, @NotNull PsiType type, @NotNull PsiType patternType) {
    if (type.equals(patternType)) return type;
    if ((type.equals(PsiTypes.byteType()) ||
         type.equals(PsiTypes.shortType())) &&
        patternType.equals(PsiTypes.charType())) {
      return PsiTypes.intType();
    }
    else if ((patternType.equals(PsiTypes.byteType()) ||
              patternType.equals(PsiTypes.shortType())) &&
             type.equals(PsiTypes.charType())) {
      return PsiTypes.intType();
    }
    else if ((type.equals(PsiTypes.intType()) &&
              patternType.equals(PsiTypes.floatType())) ||
             (type.equals(PsiTypes.floatType()) &&
              patternType.equals(PsiTypes.intType()))) {
      return PsiTypes.doubleType();
    }
    else if ((type.equals(PsiTypes.longType()) &&
              patternType.equals(PsiTypes.floatType())) ||
             (type.equals(PsiTypes.floatType()) &&
              patternType.equals(PsiTypes.longType())) ||

             (type.equals(PsiTypes.longType()) &&
              patternType.equals(PsiTypes.doubleType())) ||
             (type.equals(PsiTypes.doubleType()) &&
              patternType.equals(PsiTypes.longType()))) {
      return PsiType.getTypeByName(JAVA_MATH_BIG_DECIMAL, context.getProject(), context.getResolveScope());
    }
    else {
      return TypeConversionUtil.isAssignable(patternType, type) ? patternType : type;
    }
  }
@NotNull
  public static PsiType getExactlyPromotedType(@NotNull PsiElement context, @NotNull PsiType type, @NotNull PsiType patternType)