mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-09 20:42:52 +07:00
dfa: take into account known variable values when handling number comparisons (IDEA-126446)
This commit is contained in:
@@ -20,6 +20,11 @@
|
||||
<line>49</line>
|
||||
<description>Switch label 'case 2:' is unreachable</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>CaseAndNpe.java</file>
|
||||
<line>56</line>
|
||||
<description>Condition <code>i < 5</code> is always <code>false</code></description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>CaseAndNpe.java</file>
|
||||
<line>80</line>
|
||||
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
import java.util.Arrays;
|
||||
|
||||
class Test {
|
||||
int[] mIndex = null;
|
||||
int mSize = 0;
|
||||
|
||||
void indexValues() {
|
||||
float loadFactor = mIndex == null ? 1.f : ((float) mSize) / ((float) mIndex.length);
|
||||
|
||||
if (loadFactor < 0.25f || 0.75f <= loadFactor) {
|
||||
mIndex = new int[mSize * 2];
|
||||
}
|
||||
|
||||
mIndex[0] = -1;
|
||||
}
|
||||
}
|
||||
@@ -251,6 +251,8 @@ public class DataFlowInspectionTest extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
public void testUseInferredContracts() { doTest(); }
|
||||
|
||||
public void testNumberComparisonsWhenValueIsKnown() { doTest(); }
|
||||
|
||||
public void testParametersAreNonnullByDefault() {
|
||||
myFixture.addClass("package javax.annotation; public @interface ParametersAreNonnullByDefault {}");
|
||||
myFixture.addClass("package javax.annotation; public @interface ParametersAreNullableByDefault {}");
|
||||
|
||||
Reference in New Issue
Block a user