mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Removed special handling of getX() != null
Also fixes IDEABKL-7233 if methods are annotated as pure
This commit is contained in:
-5
@@ -942,11 +942,6 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
|
||||
final boolean containsCalls = dfaLeft instanceof DfaVariableValue && ((DfaVariableValue)dfaLeft).containsCalls();
|
||||
|
||||
// track "x" property state only inside "if (getX() != null) ..."
|
||||
if (containsCalls && !isNotNull(dfaLeft) && isNull(dfaRight) && !isNegated) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (dfaLeft == dfaRight) {
|
||||
return containsCalls || !isNegated;
|
||||
}
|
||||
|
||||
@@ -12,10 +12,11 @@ class Doo {
|
||||
boolean pureSomething() { return false;}
|
||||
|
||||
public void main2() {
|
||||
// isSomething is non-pure: flush
|
||||
if (getMethod() == null && !isSomething()) {
|
||||
return;
|
||||
} else {
|
||||
System.out.println(getMethod().<warning descr="Method invocation 'hashCode' may produce 'java.lang.NullPointerException'">hashCode</warning>());
|
||||
System.out.println(getMethod().hashCode());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
// IDEABKL7233
|
||||
public class XorNullity {
|
||||
void test(CreateForm createForm) {
|
||||
if(createForm.getOpenIdIdentity() == null ^ createForm.getOpenIdProvider() == null) {
|
||||
throw new RuntimeException("Invalid request");
|
||||
}
|
||||
|
||||
if(createForm.getOpenIdIdentity() != null) {
|
||||
findByOpenIdIdentity(createForm.getOpenIdProvider()); // never null
|
||||
}
|
||||
}
|
||||
|
||||
void test2(CreateForm createForm) {
|
||||
if(createForm.getOpenIdIdentity() == null ^ createForm.getOpenIdProvider() != null) {
|
||||
throw new RuntimeException("Invalid request");
|
||||
}
|
||||
|
||||
if(createForm.getOpenIdIdentity() != null) {
|
||||
findByOpenIdIdentity(<warning descr="Argument 'createForm.getOpenIdProvider()' might be null">createForm.getOpenIdProvider()</warning>); // nullable
|
||||
}
|
||||
}
|
||||
|
||||
void findByOpenIdIdentity(@NotNull Object identity) {}
|
||||
|
||||
interface CreateForm {
|
||||
@Nullable
|
||||
@Contract(pure = true)
|
||||
Object getOpenIdIdentity();
|
||||
|
||||
@Nullable
|
||||
@Contract(pure = true)
|
||||
Object getOpenIdProvider();
|
||||
}
|
||||
}
|
||||
@@ -578,4 +578,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public void testManyBooleans() { doTest(); }
|
||||
public void testPureNoArgMethodAsVariable() { doTest(); }
|
||||
public void testRedundantAssignment() { doTest(); }
|
||||
public void testXorNullity() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user