record (ExpectedTypeInfo[] expectedReturn, List<Pair<PsiExpression, PsiType>> arguments) { @NotNull private static ExpectedSignature from(PsiMethodReferenceExpression expression) { final PsiType functionalInterfaceType = getFunctionalExpressionType(expression); final PsiClassType.ClassResolveResult classResolveResult = PsiUtil.resolveGenericsClassInType(functionalInterfaceType); final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(classResolveResult); LOG.assertTrue(interfaceMethod != null); PsiType interfaceReturnType = LambdaUtil.getFunctionalInterfaceReturnType(functionalInterfaceType); LOG.assertTrue(interfaceReturnType != null); final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, classResolveResult); final ExpectedTypeInfo[] expectedTypes = {new ExpectedTypeInfoImpl(interfaceReturnType, ExpectedTypeInfo.TYPE_OR_SUBTYPE, interfaceReturnType, TailTypes.noneType(), null, ExpectedTypeInfoImpl.NULL)}; PsiParameter[] parameters = interfaceMethod.getParameterList().getParameters(); List<Pair<PsiExpression, PsiType>> origArgs = ContainerUtil.map(parameters, parameter -> Pair.create(null, substitutor.substitute(parameter.getType()))); return new ExpectedSignature(expectedTypes, origArgs); } }