LongRangeSet (@NotNull LongRangeSet range, int size, @NotNull PsiPrimitiveType type) { long addend = 1L << (size - 1); if (range.min() <= -addend && range.max() >= addend - 1) return Objects.requireNonNull(typeRange(type)); if (range.min() >= -addend && range.max() <= addend - 1) return range; long mask = (1L << size) - 1; return range.plus(LongRangeSet.point(addend), LongRangeType.INT64) .bitwiseAnd(LongRangeSet.point(mask)).plus(LongRangeSet.point(-addend), LongRangeType.INT64); }