private static @NotNull LongRangeSet castContinuousRange(@NotNull LongRangeSet range, @NotNull PsiPrimitiveType type) {
    if (PsiTypes.byteType().equals(type)) {
      LongRangeSet result = mask(range, Byte.SIZE, type);
      assert BYTE_RANGE.contains(result) : range;
      return result;
    }
    if (PsiTypes.shortType().equals(type)) {
      LongRangeSet result = mask(range, Short.SIZE, type);
      assert SHORT_RANGE.contains(result) : range;
      return result;
    }
    if (PsiTypes.intType().equals(type)) {
      LongRangeSet result = mask(range, Integer.SIZE, type);
      assert INT_RANGE.contains(result) : range;
      return result;
    }
    if (PsiTypes.charType().equals(type)) {
      if (range.min() <= Character.MIN_VALUE && range.max() >= Character.MAX_VALUE) return CHAR_RANGE;
      if (range.min() >= Character.MIN_VALUE && range.max() <= Character.MAX_VALUE) return range;
      return range.bitwiseAnd(LongRangeSet.point(0xFFFF));
    }
    throw new IllegalArgumentException(type.toString());
  }
private static @NotNull LongRangeSet castContinuousRange(@NotNull LongRangeSet range, @NotNull PsiPrimitiveType type)