LongRangeSet: fix abs(int) in case if original value is out-of-int range (EA-214516); asserts for casts

GitOrigin-RevId: f009c62b8fed9eee64f93e6fb7a8cb64554db2f2
This commit is contained in:
Tagir Valeev
2019-10-14 04:39:24 +00:00
committed by intellij-monorepo-bot
parent 1a40e95a73
commit 60e18c3976
@@ -1493,13 +1493,19 @@ public abstract class LongRangeSet {
public LongRangeSet castTo(PsiPrimitiveType type) {
if (PsiType.LONG.equals(type)) return this;
if (PsiType.BYTE.equals(type)) {
return mask(Byte.SIZE, type);
LongRangeSet result = mask(Byte.SIZE, type);
assert BYTE_RANGE.contains(result) : this;
return result;
}
if (PsiType.SHORT.equals(type)) {
return mask(Short.SIZE, type);
LongRangeSet result = mask(Short.SIZE, type);
assert SHORT_RANGE.contains(result) : this;
return result;
}
if (PsiType.INT.equals(type)) {
return mask(Integer.SIZE, type);
LongRangeSet result = mask(Integer.SIZE, type);
assert INT_RANGE.contains(result) : this;
return result;
}
if (PsiType.CHAR.equals(type)) {
if (myFrom <= Character.MIN_VALUE && myTo >= Character.MAX_VALUE) return CHAR_RANGE;
@@ -1535,6 +1541,9 @@ public abstract class LongRangeSet {
hi = Math.max(-low, hi);
low = 0;
}
if (low > hi) {
return isLong ? LONG_RANGE : INT_RANGE;
}
if (myFrom <= minValue) {
return new RangeSet(new long[]{minValue, minValue, low, hi});
}