mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ControlFlowAnalyzer#generateBoxingUnboxingInstructionFor: add primitive cast after unbox when necessary
Fixes IDEA-219122 False inspection result when comparing boxed values GitOrigin-RevId: c32cda24d371caacd4356cce8bdcbb40557c4ccc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
fc0d469679
commit
1d2d9236f6
+2
-1
@@ -1490,8 +1490,9 @@ public class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
|
||||
if (TypeConversionUtil.isPrimitiveAndNotNull(expectedType) && TypeConversionUtil.isPrimitiveWrapper(actualType)) {
|
||||
addInstruction(new UnwrapSpecialFieldInstruction(SpecialField.UNBOX));
|
||||
actualType = PsiPrimitiveType.getUnboxedType(actualType);
|
||||
}
|
||||
else if (TypeConversionUtil.isPrimitiveAndNotNull(actualType) && TypeConversionUtil.isAssignableFromPrimitiveWrapper(expectedType)) {
|
||||
if (TypeConversionUtil.isPrimitiveAndNotNull(actualType) && TypeConversionUtil.isAssignableFromPrimitiveWrapper(expectedType)) {
|
||||
addConditionalErrorThrow();
|
||||
PsiType boxedType = ((PsiPrimitiveType)actualType).getBoxedType(context);
|
||||
addInstruction(new BoxingInstruction(boxedType));
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
import java.util.*;
|
||||
|
||||
class Testcase {
|
||||
// IDEA-219122
|
||||
public static void boxWithCast() {
|
||||
Double d = 1D;
|
||||
Long l = 1L;
|
||||
if (<warning descr="Condition 'd.equals(Double.valueOf(l))' is always 'true'">d.equals(Double.valueOf(l))</warning>) {
|
||||
System.out.println("e. d: " + d + " l: " + l);
|
||||
} else {
|
||||
System.out.println("ne. d: " + d + " l: " + l);
|
||||
}
|
||||
}
|
||||
|
||||
void intToLong() {
|
||||
Integer i = 2;
|
||||
|
||||
Reference in New Issue
Block a user