mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Revert incorrect fixes for IDEA-184723 Data flow algorithm complexity
This reverts commits9a837e70d3and6d52b5462e.
This commit is contained in:
@@ -665,10 +665,6 @@ class StateMerger {
|
||||
|
||||
@Override
|
||||
void removeFromState(@NotNull DfaMemoryStateImpl state) {
|
||||
if(!myPositive && state.isNotNull(myVar) && state.isNull(myArg)) {
|
||||
// merging "x == null" and "x != null" should be possible with marking "x" as nullable
|
||||
state.forceVariableFact(myVar, CAN_BE_NULL, true);
|
||||
}
|
||||
state.removeEquivalenceRelations(myVar);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
class NullabilityBasics {
|
||||
|
||||
void test2() {
|
||||
String x = getNullable();
|
||||
if (x == null) {
|
||||
System.out.println("x is null!");
|
||||
}
|
||||
if (isEmpty(x) && Math.random() > 0.5) {
|
||||
return;
|
||||
}
|
||||
System.out.println(x.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>());
|
||||
}
|
||||
|
||||
@Nullable String getNullable() {
|
||||
return Math.random() > 0.5 ? null : "";
|
||||
}
|
||||
|
||||
@Contract(value = "null -> true",pure = true)
|
||||
static boolean isEmpty(@Nullable String s) {
|
||||
return s == null || s.isEmpty();
|
||||
}
|
||||
|
||||
void test(String x) {
|
||||
if (x == null) {
|
||||
System.out.println("x is null!");
|
||||
}
|
||||
System.out.println(x.<warning descr="Method invocation 'trim' may produce 'java.lang.NullPointerException'">trim</warning>());
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
import java.util.Optional;
|
||||
|
||||
// IDEA-184723
|
||||
class OptionalTooComplex {
|
||||
// Should not be too complex
|
||||
public Long fetch() {
|
||||
final PreparedStatement ps = builder
|
||||
.setInteger(<warning descr="Argument 'opt().orElse(null)' might be null but passed to non annotated parameter">opt().orElse(null)</warning>)
|
||||
.setInteger(<warning descr="Argument 'opt().orElse(null)' might be null but passed to non annotated parameter">opt().orElse(null)</warning>)
|
||||
.setInteger(<warning descr="Argument 'opt().orElse(null)' might be null but passed to non annotated parameter">opt().orElse(null)</warning>)
|
||||
.setInteger(<warning descr="Argument 'opt().orElse(null)' might be null but passed to non annotated parameter">opt().orElse(null)</warning>)
|
||||
.setInteger(<warning descr="Argument 'opt().orElse(null)' might be null but passed to non annotated parameter">opt().orElse(null)</warning>)
|
||||
.build();
|
||||
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
rs = ps.executeQuery();
|
||||
if (rs.next()) {
|
||||
return rs.getLong();
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
interface ResultSet {
|
||||
boolean next() throws Exception;
|
||||
|
||||
long getLong() throws Exception;
|
||||
}
|
||||
|
||||
interface PreparedStatement {
|
||||
ResultSet executeQuery() throws Exception;
|
||||
}
|
||||
|
||||
native Optional<Integer> opt();
|
||||
|
||||
interface QueryBuilder {
|
||||
QueryBuilder setInteger(Integer value);
|
||||
|
||||
PreparedStatement build();
|
||||
}
|
||||
|
||||
QueryBuilder builder;
|
||||
}
|
||||
@@ -220,6 +220,4 @@ public class DataFlowInspection8Test extends DataFlowInspectionTestCase {
|
||||
public void testPrimitiveGetters() { doTest(); }
|
||||
public void testUnknownOnStack() { doTest(); }
|
||||
public void testMapUpdateInlining() { doTestWithCustomAnnotations(); }
|
||||
|
||||
public void testOptionalTooComplex() { doTest(); }
|
||||
}
|
||||
@@ -582,6 +582,5 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public void testPrimitiveNull() { doTest(); }
|
||||
public void testLessThanRelations() { doTest(); }
|
||||
public void testAdvancedArrayAccess() { doTest(); }
|
||||
public void testNullabilityBasics() { doTest(); }
|
||||
public void testNullableGetterInLoop() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user