@NotNull
  private static PsiType lub(@Nullable PsiType currentType,
                             @NotNull PsiType leastValueType,
                             @NotNull PsiType valueType,
                             @NotNull PsiMethod method,
                             @NotNull PsiManager manager) {
    if (currentType == null || PsiTypes.voidType().equals(currentType)) return valueType;
    if (currentType == valueType) return currentType;

    if (TypeConversionUtil.isPrimitiveAndNotNull(valueType)) {
      if (TypeConversionUtil.isPrimitiveAndNotNull(currentType)) {
        int r1 = TypeConversionUtil.getTypeRank(currentType);
        int r2 = TypeConversionUtil.getTypeRank(leastValueType);
        return r1 >= r2 ? currentType : valueType;
      }
      PsiPrimitiveType unboxedType = PsiPrimitiveType.getUnboxedType(currentType);
      if (valueType.equals(unboxedType)) return currentType;
      PsiClassType boxedType = ((PsiPrimitiveType)valueType).getBoxedType(method);
      if (boxedType == null) return valueType;
      valueType = boxedType;
    }

    if (TypeConversionUtil.isPrimitiveAndNotNull(currentType)) {
      currentType = ((PsiPrimitiveType)currentType).getBoxedType(method);
    }

    return Objects.requireNonNullElse(GenericsUtil.getLeastUpperBound(currentType, valueType, manager), Objects.requireNonNullElse(currentType, valueType));
  }
@NotNull
  private static PsiType lub(@Nullable PsiType currentType,
                             @NotNull PsiType leastValueType,
                             @NotNull PsiType valueType,
                             @NotNull PsiMethod method,
                             @NotNull PsiManager manager)