mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-03-22 15:19:59 +07:00
[java-dfa] Do not flush the pure method result facts
Otherwise, we lose locality GitOrigin-RevId: aed2cd27ea1c412f16deaaea346791484e02f390
This commit is contained in:
committed by
intellij-monorepo-bot
parent
31b989d0cd
commit
c2e018c7e3
@@ -79,6 +79,7 @@ public final class DfaCallArguments {
|
||||
// We assume that even pure call may modify private fields (e.g., to cache something)
|
||||
state.flushVariables(v -> v.getQualifier() == qualifier &&
|
||||
v.getPsiVariable() instanceof PsiMember member &&
|
||||
member != method &&
|
||||
member.hasModifierProperty(PsiModifier.PRIVATE));
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.assertj.core.api;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.*;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.*;
|
||||
|
||||
@@ -37,6 +37,10 @@ class Sample {
|
||||
Assertions.assertThat(stream).isEmpty();
|
||||
}
|
||||
|
||||
// All methods inside the org.assertj.core.api package are hardcoded to be pure by default
|
||||
// See com.intellij.codeInsight.DefaultInferredAnnotationProvider.getHardcodedContractAnnotation
|
||||
// We override this, otherwise it spoils the tests, as it's assumed that the same value is always returned
|
||||
@Contract(pure = false)
|
||||
private native Optional<String> getOptional();
|
||||
|
||||
public void testAs() {
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
public class FieldLocalNoAliasing {
|
||||
static class X {
|
||||
int a = 1;
|
||||
}
|
||||
|
||||
void noAliasingPossible(X b) {
|
||||
X x = getX();
|
||||
x.a = 1;
|
||||
b.a = 211;
|
||||
if (<warning descr="Condition 'x.a == 1' is always 'true'">x.a == 1</warning>) {
|
||||
System.out.println("1");
|
||||
}
|
||||
}
|
||||
|
||||
@Contract(value="->new", pure=true)
|
||||
private X getX(){
|
||||
X x = new X();
|
||||
return x;
|
||||
}
|
||||
}
|
||||
@@ -762,5 +762,6 @@ public class DataFlowInspectionTest extends DataFlowInspectionTestCase {
|
||||
public void testAssignAndReturnVolatile() { doTest(); }
|
||||
public void testQualifiedValueFromConstant() { doTest();}
|
||||
public void testFieldAliasing() { doTest();}
|
||||
public void testFieldLocalNoAliasing() { doTest();}
|
||||
public void testIoContracts() { doTest(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user