mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
string comparison: evaluate based on equals comparison (IDEA-160823)
This commit is contained in:
@@ -247,7 +247,7 @@ class ConstantExpressionVisitor extends JavaElementVisitor implements PsiConstan
|
||||
value = Boolean.valueOf(((Number)lOperandValue).doubleValue() == ((Number)rOperandValue).doubleValue());
|
||||
}
|
||||
else if (lOperandValue instanceof String && rOperandValue instanceof String) {
|
||||
value = Boolean.valueOf(lOperandValue == rOperandValue);
|
||||
value = Boolean.valueOf(lOperandValue.equals(rOperandValue));
|
||||
}
|
||||
else if (lOperandValue instanceof Boolean && rOperandValue instanceof Boolean) {
|
||||
value = Boolean.valueOf(((Boolean)lOperandValue).booleanValue() == ((Boolean)rOperandValue).booleanValue());
|
||||
@@ -260,7 +260,7 @@ class ConstantExpressionVisitor extends JavaElementVisitor implements PsiConstan
|
||||
value = Boolean.valueOf(((Number)lOperandValue).doubleValue() != ((Number)rOperandValue).doubleValue());
|
||||
}
|
||||
else if (lOperandValue instanceof String && rOperandValue instanceof String) {
|
||||
value = Boolean.valueOf(lOperandValue != rOperandValue);
|
||||
value = Boolean.valueOf(!lOperandValue.equals(rOperandValue));
|
||||
}
|
||||
else if (lOperandValue instanceof Boolean && rOperandValue instanceof Boolean) {
|
||||
value = Boolean.valueOf(((Boolean)lOperandValue).booleanValue() != ((Boolean)rOperandValue).booleanValue());
|
||||
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
|
||||
class Bar {
|
||||
public static final String T = "";
|
||||
|
||||
void m0() {
|
||||
while (T == "") {
|
||||
f();
|
||||
}
|
||||
<error descr="Unreachable statement">f();</error>
|
||||
}
|
||||
|
||||
void m() {
|
||||
while (T == "a") {
|
||||
<error descr="Unreachable statement">f();</error>
|
||||
}
|
||||
}
|
||||
|
||||
void m01() {
|
||||
while (T != "") {
|
||||
<error descr="Unreachable statement">f();</error>
|
||||
}
|
||||
}
|
||||
|
||||
void m1() {
|
||||
while (T != "a") {
|
||||
f();
|
||||
}
|
||||
<error descr="Unreachable statement">f();</error>
|
||||
}
|
||||
|
||||
void m2() {
|
||||
while (T != T) {
|
||||
<error descr="Unreachable statement">f();</error>
|
||||
}
|
||||
}
|
||||
|
||||
void m3() {
|
||||
while (T == T) {}
|
||||
<error descr="Unreachable statement">f();</error>
|
||||
}
|
||||
|
||||
private void f() {}
|
||||
}
|
||||
+4
@@ -94,4 +94,8 @@ public class LightAdvHighlightingJdk6Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testStaticOnDemandImportResolvesToClass() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
|
||||
public void testReachableWhileBodyDueToConstantStringComparison() throws Exception {
|
||||
doTest(false, false);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user