PsiType (PsiExpression forPlace, boolean honorAssignments) { PsiType type = forPlace.getType(); TypeConstraint initial = type == null ? TypeConstraints.TOP : TypeConstraints.instanceOf(type); PsiElement scope = DfaPsiUtil.getTopmostBlockInSameClass(forPlace); if (scope == null) { PsiFile file = forPlace.getContainingFile(); if (!(file instanceof PsiCodeFragment)) { return null; } scope = file; } GuessManagerRunner runner = new GuessManagerRunner(scope.getProject(), honorAssignments, forPlace); class MyListener implements JavaDfaListener { TypeConstraint constraint = TypeConstraints.BOTTOM; @Override public void beforeExpressionPush(@NotNull DfaValue value, @NotNull PsiExpression expression, @NotNull DfaMemoryState state) { if (expression == forPlace) { if (!(value instanceof DfaVariableValue) || ((DfaVariableValue)value).isFlushableByCalls()) { value = value.getFactory().getVarFactory().createVariableValue(new ExpressionVariableDescriptor(expression)); } constraint = constraint.join(TypeConstraint.fromDfType(state.getDfType(value))); runner.placeVisited(); } } } var interceptor = new MyListener(); RunnerResult result = runner.analyzeMethodWithInlining(scope, interceptor); if (result == RunnerResult.OK || result == RunnerResult.CANCELLED) { return interceptor.constraint.meet(initial).getPsiType(scope.getProject()); } return null; }