mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
DfaUtil#isComparedByEquals inlined
GitOrigin-RevId: e3854b23708fbe6d12909ca5143a58e549af0c71
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cbe2eb0d8f
commit
1ddf0f9e38
+2
-2
@@ -227,8 +227,8 @@ class DebuggerDfaRunner extends DataFlowRunner {
|
||||
|
||||
void finish() {
|
||||
if (myChanged) {
|
||||
DfaVariableValue[] distinctValues =
|
||||
StreamEx.ofValues(myCanonicalMap).filter(v -> v.getType() != null && !DfaUtil.isComparedByEquals(v.getType()))
|
||||
DfaVariableValue[] distinctValues = StreamEx.ofValues(myCanonicalMap)
|
||||
.filter(v -> v.getType() != null && !TypeConstraints.exact(v.getType()).isComparedByEquals())
|
||||
.toArray(new DfaVariableValue[0]);
|
||||
EntryStream.ofPairs(distinctValues)
|
||||
.filterKeyValue(
|
||||
|
||||
@@ -302,10 +302,6 @@ public class DfaUtil {
|
||||
return tryCast(ContainerUtil.getOnlyItem(result.getExpressionValues(condition)), Boolean.class);
|
||||
}
|
||||
|
||||
public static boolean isComparedByEquals(PsiType type) {
|
||||
return type != null && TypeConstraints.exact(type).isComparedByEquals();
|
||||
}
|
||||
|
||||
public static DfaValue boxUnbox(DfaValue value, @Nullable PsiType type) {
|
||||
if (TypeConversionUtil.isPrimitiveWrapper(type)) {
|
||||
if (TypeConversionUtil.isPrimitiveAndNotNull(value.getType())) {
|
||||
|
||||
+8
-5
@@ -265,11 +265,14 @@ public class HardcodedContracts {
|
||||
|
||||
private static List<MethodContract> equalsContracts(PsiMethodCallExpression call) {
|
||||
PsiExpression qualifier = call == null ? null : call.getMethodExpression().getQualifierExpression();
|
||||
if (qualifier != null && (knownAsEqualByReference(qualifier.getType()) || DfaUtil.isComparedByEquals(qualifier.getType()))) {
|
||||
return Arrays.asList(
|
||||
singleConditionContract(ContractValue.qualifier(), RelationType.EQ, ContractValue.argument(0), returnTrue()),
|
||||
trivialContract(returnFalse())
|
||||
);
|
||||
if (qualifier != null) {
|
||||
PsiType type = qualifier.getType();
|
||||
if (type != null && (knownAsEqualByReference(type) || TypeConstraints.exact(type).isComparedByEquals())) {
|
||||
return Arrays.asList(
|
||||
singleConditionContract(ContractValue.qualifier(), RelationType.EQ, ContractValue.argument(0), returnTrue()),
|
||||
trivialContract(returnFalse())
|
||||
);
|
||||
}
|
||||
}
|
||||
return Arrays.asList(new StandardMethodContract(new StandardMethodContract.ValueConstraint[]{NULL_VALUE}, returnFalse()),
|
||||
singleConditionContract(ContractValue.qualifier(), RelationType.EQ,
|
||||
|
||||
+3
-3
@@ -454,15 +454,15 @@ public class StandardInstructionVisitor extends InstructionVisitor {
|
||||
PsiMethodReferenceExpression context = (PsiMethodReferenceExpression)instruction.getContext();
|
||||
value = dereference(memState, value, NullabilityProblemKind.callMethodRefNPE.problem(context, null));
|
||||
}
|
||||
if (sig.mutatesThis() && Mutability.fromDfType(memState.getDfType(value)).isUnmodifiable()) {
|
||||
DfType dfType = memState.getDfType(value);
|
||||
if (sig.mutatesThis() && Mutability.fromDfType(dfType).isUnmodifiable()) {
|
||||
reportMutabilityViolation(true, instruction.getContext());
|
||||
DfType dfType = memState.getDfType(value);
|
||||
if (dfType instanceof DfReferenceType) {
|
||||
memState.setDfType(value, ((DfReferenceType)dfType).dropMutability().meet(Mutability.MUTABLE.asDfType()));
|
||||
}
|
||||
}
|
||||
if (!(value.getType() instanceof PsiArrayType) &&
|
||||
(DfaUtil.isComparedByEquals(value.getType()) ||
|
||||
(TypeConstraint.fromDfType(dfType).isComparedByEquals() ||
|
||||
instruction.shouldFlushFields() || !(instruction.getResultType() instanceof PsiPrimitiveType))) {
|
||||
// For now drop locality on every qualified call except primitive returning pure calls
|
||||
// as value might escape through the return value
|
||||
|
||||
Reference in New Issue
Block a user