CFGBuilder (int argCount, @Nullable PsiExpression functionalExpression, Nullability resultNullability) { PsiExpression stripped = PsiUtil.deparenthesizeExpression(functionalExpression); if (tryInlineLambda(argCount, functionalExpression, resultNullability, () -> {})) return this; if (stripped instanceof PsiMethodReferenceExpression methodRef) { JavaResolveResult resolveResult = methodRef.advancedResolve(false); PsiMethod method = ObjectUtils.tryCast(resolveResult.getElement(), PsiMethod.class); if (method != null && !method.isVarArgs()) { if (argCount == 1) { add(new ResultOfInstruction(new JavaMethodReferenceArgumentAnchor(methodRef))); } if (processKnownMethodReference(argCount, methodRef, method)) return this; int expectedArgCount = method.getParameterList().getParametersCount(); boolean pushQualifier = true; if (!method.hasModifierProperty(PsiModifier.STATIC) && !method.isConstructor()) { pushQualifier = !PsiMethodReferenceUtil.isStaticallyReferenced(methodRef); if (!pushQualifier) { expectedArgCount++; // qualifier is already on stack for statically referenced method ref } } if (argCount == expectedArgCount) { if (pushQualifier) { DfaValue qualifierValue = myMethodRefQualifiers.remove(methodRef); push(qualifierValue == null ? getFactory().getUnknown() : qualifierValue); moveTopValue(argCount); } myAnalyzer.addBareCall(null, methodRef); myAnalyzer.generateBoxingUnboxingInstructionFor(methodRef, resolveResult.getSubstitutor().substitute(method.getReturnType()), LambdaUtil.getFunctionalInterfaceReturnType(methodRef), false); if (resultNullability == Nullability.NOT_NULL) { myAnalyzer.addNullCheck(NullabilityProblemKind.nullableFunctionReturn.problem(methodRef, null)); } return this; } } PsiElement qualifier = methodRef.getQualifier(); if (qualifier instanceof PsiTypeElement && ((PsiTypeElement)qualifier).getType() instanceof PsiArrayType) { // like String[]::new splice(argCount) .push(DfTypes.typedObject(((PsiTypeElement)qualifier).getType(), Nullability.NOT_NULL)); return this; } } if (stripped instanceof PsiMethodCallExpression && PREDICATE_NOT.test((PsiMethodCallExpression)stripped)) { invokeFunction(argCount, ((PsiMethodCallExpression)stripped).getArgumentList().getExpressions()[0], resultNullability); myAnalyzer.addInstruction(new NotInstruction(null)); return this; } splice(argCount); if (functionalExpression == null) { pushUnknown(); return this; } // Unknown function flushFields(); myAnalyzer.addConditionalErrorThrow(); PsiType functionalInterfaceType = functionalExpression.getType(); myAnalyzer.addMethodThrows(LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType)); PsiType returnType = LambdaUtil.getFunctionalInterfaceReturnType(functionalInterfaceType); if (returnType != null) { push(DfTypes.typedObject(returnType, DfaPsiUtil.getTypeNullability(returnType))); } else { pushUnknown(); } return this; }