mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
ControlFlowAnalyzer#acceptBinaryRightOperand: properly convert type for comparison
Fixes IDEA-200364 Checking equality between int and double confuses "Constant condition and exception" inspection
This commit is contained in:
+1
-1
@@ -1423,7 +1423,7 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
TypeConversionUtil.isNumericType(lType) &&
|
||||
TypeConversionUtil.isNumericType(rType);
|
||||
|
||||
PsiType castType = comparingPrimitiveNumeric ? TypeConversionUtil.isFloatOrDoubleType(lType) ? PsiType.DOUBLE : PsiType.LONG : type;
|
||||
PsiType castType = comparingPrimitiveNumeric ? TypeConversionUtil.unboxAndBalanceTypes(lType, rType) : type;
|
||||
|
||||
if (!comparingRef) {
|
||||
generateBoxingUnboxingInstructionFor(lExpr,castType);
|
||||
|
||||
@@ -5,4 +5,12 @@ class WideningToDouble {
|
||||
boolean trueValue = <warning descr="Condition 'x == y' is always 'true'">x == y</warning>; // ASSIGNMENT
|
||||
System.out.println(trueValue); // prints "true"
|
||||
}
|
||||
|
||||
void test() {
|
||||
int y = 2;
|
||||
if (<warning descr="Condition 'y == 2.1' is always 'false'">y == 2.1</warning>) {
|
||||
System.out.println("true");
|
||||
} else
|
||||
System.out.println("false");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user