diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaBinOpValue.java b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaBinOpValue.java index bbe5a9294aec..e8785239b6a0 100644 --- a/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaBinOpValue.java +++ b/java/java-analysis-impl/src/com/intellij/codeInspection/dataFlow/value/DfaBinOpValue.java @@ -9,6 +9,7 @@ import com.intellij.psi.JavaTokenType; import com.intellij.psi.PsiPrimitiveType; import com.intellij.psi.PsiType; import com.intellij.psi.tree.IElementType; +import com.intellij.psi.util.TypeConversionUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -81,6 +82,7 @@ public class DfaBinOpValue extends DfaValue { @NotNull public DfaValue tryReduceOnCast(DfaMemoryState state, PsiPrimitiveType type) { + if (!TypeConversionUtil.isIntegralNumberType(type)) return this; if ((myOp == BinOp.PLUS || myOp == BinOp.MINUS) && DfLongType.extractRange(state.getDfType(myRight)).castTo(type).equals(LongRangeSet.point(0))) { return myLeft; diff --git a/java/java-tests/testData/inspection/dataFlow/fixture/ReduceBinOpOnCast.java b/java/java-tests/testData/inspection/dataFlow/fixture/ReduceBinOpOnCast.java index ef86e5db9e9f..2312785c76a0 100644 --- a/java/java-tests/testData/inspection/dataFlow/fixture/ReduceBinOpOnCast.java +++ b/java/java-tests/testData/inspection/dataFlow/fixture/ReduceBinOpOnCast.java @@ -16,4 +16,14 @@ public class ReduceBinOpOnCast { if (res == b) {} } } + + void testTwoChecks(int a, short b) { + if (a == 0x10000 || a == 0x20000 || a == 0) { + b += a; + } + } + + void testDoubleCast(int x) { + double d = x + 1; + } }