void (@NotNull DfType dfType, @NotNull JavaDfaAnchor anchor, @NotNull ProblemsHolder reporter) { ConstantResult result = ConstantResult.fromDfType(dfType); if (result == ConstantResult.UNKNOWN && dfType instanceof DfReferenceType refType && refType.getSpecialField() == SpecialField.UNBOX && refType.getNullability() == DfaNullability.NOT_NULL) { result = ConstantResult.fromDfType(refType.getSpecialFieldType()); } if (result == ConstantResult.UNKNOWN) return; Object value = result.value(); if (anchor instanceof JavaPolyadicPartAnchor polyadicPartAnchor) { if (value instanceof Boolean booleanValue) { // report rare cases like a == b == c where "a == b" part is constant String message = JavaAnalysisBundle.message("dataflow.message.constant.condition", booleanValue.booleanValue() ? 1 : 0); reporter.registerProblem(polyadicPartAnchor.getExpression(), polyadicPartAnchor.getTextRange(), message); // do not add to reported anchors if only part of expression was reported } } else if (anchor instanceof JavaExpressionAnchor expressionAnchor) { PsiExpression expression = expressionAnchor.getExpression(); if (isCondition(expression)) { if (value instanceof Boolean booleanValue) { reportConstantBoolean(reporter, expression, booleanValue); } } else { reportConstantReferenceValue(reporter, expression, result); } } else if (anchor instanceof JavaMethodReferenceReturnAnchor methodRefAnchor) { PsiMethodReferenceExpression methodRef = methodRefAnchor.getMethodReferenceExpression(); PsiMethod method = tryCast(methodRef.resolve(), PsiMethod.class); if (method != null && JavaMethodContractUtil.isPure(method)) { List<StandardMethodContract> contracts = JavaMethodContractUtil.getMethodContracts(method); if (contracts.isEmpty() || !contracts.get(0).isTrivial()) { reporter.registerProblem(methodRef, JavaAnalysisBundle.message("dataflow.message.constant.method.reference", value), new ReplaceWithTrivialLambdaFix(value)); } } } }