Microsoft.CSharp.RuntimeBinder.Semantics.MethodTypeInferrer.MethodGroupReturnTypeInference C# (CSharp) Метод

MethodGroupReturnTypeInference() приватный Метод

private MethodGroupReturnTypeInference ( EXPR pSource, CType pType ) : bool
pSource EXPR
pType CType
Результат bool
        private bool MethodGroupReturnTypeInference(EXPR pSource, CType pType)
        {
            // SPEC:  Otherwise, if E is a method group and T is a delegate CType or
            // SPEC:   expression tree CType with parameter types T1...Tk and return
            // SPEC:   CType Tb and overload resolution of E with the types T1...Tk
            // SPEC:   yields a single method with return CType U then a lower-bound
            // SPEC:   inference is made from U to Tb.

            if (!pSource.isMEMGRP())
            {
                return false;
            }
            pType = pType.GetDelegateTypeOfPossibleExpression();
            if (!pType.isDelegateType())
            {
                return false;
            }
            AggregateType pDelegateType = pType.AsAggregateType();
            CType pDelegateReturnType = pDelegateType.GetDelegateReturnType(GetSymbolLoader());
            if (pDelegateReturnType == null)
            {
                return false;
            }
            if (pDelegateReturnType.IsVoidType())
            {
                return false;
            }

            // At this point we are in the second phase; we know that all the input types are fixed.

            TypeArray pDelegateParameters = GetFixedDelegateParameters(pDelegateType);
            if (pDelegateParameters == null)
            {
                return false;
            }

            ArgInfos argInfo = new ArgInfos() { carg = pDelegateParameters.size, types = pDelegateParameters, fHasExprs = false, prgexpr = null };

            var argsBinder = new ExpressionBinder.GroupToArgsBinder(_binder, 0/* flags */, pSource.asMEMGRP(), argInfo, null, false, pDelegateType);

            bool success = argsBinder.Bind(false);
            if (!success)
            {
                return false;
            }

            MethPropWithInst mwi = argsBinder.GetResultsOfBind().GetBestResult();
            CType pMethodReturnType = GetTypeManager().SubstType(mwi.Meth().RetType,
                mwi.GetType(), mwi.TypeArgs);
            if (pMethodReturnType.IsVoidType())
            {
                return false;
            }

            LowerBoundInference(pMethodReturnType, pDelegateReturnType);
            return true;
        }