LongRangeSet (@NotNull LongRangeSet other) { if (other instanceof Point p) { if (p.myValue == myFrom) { return modRange(myFrom + 1, myTo, myMod, myBits); } if (p.myValue == myTo) { return modRange(myFrom, myTo - 1, myMod, myBits); } } if (other instanceof Range r && !(other instanceof ModRange)) { if (r.myFrom <= myFrom && r.myTo >= myFrom && r.myTo < myTo) { return modRange(r.myTo + 1, myTo, myMod, myBits); } if (r.myFrom > myFrom && r.myFrom <= myTo && r.myTo >= myTo) { return modRange(myFrom, r.myFrom - 1, myMod, myBits); } } return super.subtract(other); }