DfaValue (@NotNull DfaCallArguments callArguments, @NotNull DfaMemoryState state, @NotNull DfaValueFactory factory, PsiMethod realMethod) { if (callArguments.getArguments() != null && myTargetMethod != null) { CustomMethodHandlers.CustomMethodHandler handler = CustomMethodHandlers.find(myTargetMethod); if (handler != null) { DfaValue value = handler.getMethodResultValue(callArguments, state, factory, myTargetMethod); if (value != null) { if (myPrecalculatedReturnValue != null) { if (!state.applyCondition(myPrecalculatedReturnValue.eq(value))) { throw new IllegalStateException("Precalculated value " + myPrecalculatedReturnValue + " mismatches with method handler result " + value + "; method = " + PsiFormatUtil.formatMethod(myTargetMethod, PsiSubstitutor.EMPTY, PsiFormatUtilBase.SHOW_CONTAINING_CLASS | PsiFormatUtilBase.SHOW_NAME, PsiFormatUtilBase.SHOW_TYPE)); } } return myPrecalculatedReturnValue instanceof DfaVariableValue var && !var.isFlushableByCalls() ? myPrecalculatedReturnValue : value; } } } DfaValue qualifierValue = callArguments.getQualifier(); PsiType type = getResultType(); VariableDescriptor descriptor = JavaDfaValueFactory.getAccessedVariableOrGetter(realMethod); if (descriptor instanceof SpecialField || descriptor != null && qualifierValue instanceof DfaVariableValue) { return descriptor.createValue(factory, qualifierValue); } if (myPrecalculatedReturnValue != null) { return myPrecalculatedReturnValue; } if (type != null && !(type instanceof PsiPrimitiveType)) { Nullability nullability = myReturnNullability; Mutability mutable = Mutability.UNKNOWN; if (myTargetMethod != null) { if (realMethod != myTargetMethod) { nullability = DfaPsiUtil.getElementNullability(type, realMethod); mutable = Mutability.getMutability(realMethod); } else { mutable = Mutability.getMutability(myTargetMethod); } PsiType qualifierType = DfaPsiUtil.dfTypeToPsiType(factory.getProject(), state.getDfType(qualifierValue)); type = narrowReturnType(type, qualifierType, realMethod); } DfType dfType = getContext() instanceof PsiNewExpression ? TypeConstraints.exact(type).asDfType().meet(NOT_NULL_OBJECT) : TypeConstraints.instanceOf(type).asDfType().meet(DfaNullability.fromNullability(nullability).asDfType()); if (myMutation.isPure() && getContext() instanceof PsiNewExpression && !TypeConstraint.fromDfType(dfType).isComparedByEquals()) { dfType = dfType.meet(LOCAL_OBJECT); } if (InheritanceUtil.isInheritor(type, JAVA_UTIL_STREAM_BASE_STREAM)) { dfType = dfType.meet(((DfReferenceType)CONSUMED_STREAM.asDfType(DfStreamStateType.OPEN)).dropNullability()); if (myReturnNullability == Nullability.NOT_NULL) { dfType = dfType.meet(LOCAL_OBJECT); } } return factory.fromDfType(dfType.meet(mutable.asDfType())); } LongRangeSet range = JvmPsiRangeSetUtil.typeRange(type, true); if (range != null) { if (myTargetMethod != null) { range = range.meet(JvmPsiRangeSetUtil.fromPsiElement(myTargetMethod)); } return factory.fromDfType(PsiTypes.longType().equals(type) ? longRange(range) : intRangeClamped(range)); } return PsiTypes.voidType().equals(type) ? factory.getUnknown() : factory.fromDfType(typedObject(type, Nullability.UNKNOWN)); }