mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DFA: remove CAN_BE_NULL fact in removeEquivalenceRelations to allow merging null and not-null vars
Fixes IDEA-184723 Data flow algorithm complexity
This commit is contained in:
+7
@@ -1298,6 +1298,13 @@ public class DfaMemoryStateImpl implements DfaMemoryState {
|
||||
final int idPlain = varPlain.getID();
|
||||
final int idNegated = varNegated == null ? -1 : varNegated.getID();
|
||||
|
||||
if(isNull(varPlain) || isNotNull(varPlain)) {
|
||||
DfaVariableState state = myVariableStates.get(varPlain);
|
||||
if (state != null) {
|
||||
setVariableState(varPlain, state.withoutFact(DfaFactType.CAN_BE_NULL));
|
||||
}
|
||||
}
|
||||
|
||||
int[] classes = myIdToEqClassesIndices.get(idPlain);
|
||||
int[] negatedClasses = myIdToEqClassesIndices.get(idNegated);
|
||||
int[] result = ArrayUtil
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
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,4 +220,6 @@ public class DataFlowInspection8Test extends DataFlowInspectionTestCase {
|
||||
public void testPrimitiveGetters() { doTest(); }
|
||||
public void testUnknownOnStack() { doTest(); }
|
||||
public void testMapUpdateInlining() { doTestWithCustomAnnotations(); }
|
||||
|
||||
public void testOptionalTooComplex() { doTest(); }
|
||||
}
|
||||
Reference in New Issue
Block a user