Nullability (@NotNull PsiParameterListOwner owner, boolean suppressNullable) { PsiElement body = owner.getBody(); if (body == null) return Nullability.UNKNOWN; final var dfaRunner = new StandardDataFlowRunner(owner.getProject()); final class BlockNullabilityListener implements JavaDfaListener { boolean hasNulls = false; boolean hasNotNulls = false; boolean hasUnknowns = false; @Override public void beforeValueReturn(@NotNull DfaValue value, @Nullable PsiExpression expression, @NotNull PsiElement context, @NotNull DfaMemoryState state) { if (context == owner && expression != null) { DfaNullability nullability = DfaNullability.fromDfType(state.getDfType(value)); if (TypeConversionUtil.isPrimitiveAndNotNull(expression.getType()) || nullability == DfaNullability.NOT_NULL) { hasNotNulls = true; } else if (nullability == DfaNullability.NULL) { hasNulls = true; } else if (nullability == DfaNullability.NULLABLE) { hasNulls = hasNotNulls = true; } else { hasUnknowns = true; } } } } var interceptor = new BlockNullabilityListener(); final RunnerResult rc = dfaRunner.analyzeMethod(body, interceptor); if (rc == RunnerResult.OK) { if (interceptor.hasNulls) { return suppressNullable ? Nullability.UNKNOWN : Nullability.NULLABLE; } if (interceptor.hasNotNulls && !interceptor.hasUnknowns) { return Nullability.NOT_NULL; } } return Nullability.UNKNOWN; }