mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-61127 (bad inspection for IF statement)
This commit is contained in:
+16
@@ -320,11 +320,19 @@ public class SimplifiableIfStatementInspection extends BaseInspection {
|
||||
if (thenReturn == null) {
|
||||
return false;
|
||||
}
|
||||
final PsiType thenType = thenReturn.getType();
|
||||
if (!PsiType.BOOLEAN.equals(thenType)) {
|
||||
return false;
|
||||
}
|
||||
final PsiExpression elseReturn =
|
||||
((PsiReturnStatement)elseBranch).getReturnValue();
|
||||
if (elseReturn == null) {
|
||||
return false;
|
||||
}
|
||||
final PsiType elseType = elseReturn.getType();
|
||||
if (!PsiType.BOOLEAN.equals(elseType)) {
|
||||
return false;
|
||||
}
|
||||
final boolean thenConstant = BoolUtils.isFalse(thenReturn) ||
|
||||
BoolUtils.isTrue(thenReturn);
|
||||
final boolean elseConstant = BoolUtils.isFalse(elseReturn) ||
|
||||
@@ -368,10 +376,18 @@ public class SimplifiableIfStatementInspection extends BaseInspection {
|
||||
if (thenRhs == null) {
|
||||
return false;
|
||||
}
|
||||
final PsiType thenRhsType = thenRhs.getType();
|
||||
if (!PsiType.BOOLEAN.equals(thenRhsType)) {
|
||||
return false;
|
||||
}
|
||||
final PsiExpression elseRhs = elseExpression.getRExpression();
|
||||
if (elseRhs == null) {
|
||||
return false;
|
||||
}
|
||||
final PsiType elseRhsType = elseRhs.getType();
|
||||
if (!PsiType.BOOLEAN.equals(elseRhsType)) {
|
||||
return false;
|
||||
}
|
||||
final boolean thenConstant = BoolUtils.isFalse(thenRhs) ||
|
||||
BoolUtils.isTrue(thenRhs);
|
||||
final boolean elseConstant = BoolUtils.isFalse(elseRhs) ||
|
||||
|
||||
+17
@@ -82,4 +82,21 @@ public class SimplifiableIfStatement {
|
||||
|
||||
return c || d;
|
||||
}
|
||||
|
||||
Boolean wrong1(int i) {
|
||||
if (i == 3) {
|
||||
return null;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void wrong2(int i) {
|
||||
Boolean a;
|
||||
if (i == 3) {
|
||||
a = null;
|
||||
} else {
|
||||
a = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user