public override IReturnType ResolveReturnType(IReturnType[] parameterTypes) { if (lambdaExpression == null) { return(ResolveReturnType()); } try { MemberLookupHelper.Log("LambdaReturnType: SetImplicitLambdaParameterTypes ", parameterTypes); resolver.SetImplicitLambdaParameterTypes(lambdaExpression, parameterTypes); return(ResolveReturnType()); } finally { resolver.UnsetImplicitLambdaParameterTypes(lambdaExpression); } }
public override IReturnType ResolveReturnType() { MemberLookupHelper.Log("LambdaReturnType: ResolveReturnType"); IReturnType result; if (returnExpressions.Count == 0) { result = resolver.ProjectContent.SystemTypes.Void; } else { result = returnExpressions.Select(rt => resolver.ResolveInternal(rt, ExpressionContext.Default)) .Select(rr => rr != null ? rr.ResolvedType : null) .Aggregate((rt1, rt2) => MemberLookupHelper.GetCommonType(resolver.ProjectContent, rt1, rt2)); } MemberLookupHelper.Log("LambdaReturnType: inferred " + result); return(result); }
public static IMethodOrProperty FindOverload(IList <IMethodOrProperty> list, IReturnType[] arguments, bool allowAdditionalArguments, bool substituteInferredTypes, out bool acceptableMatch) { OverloadResolution or = new OverloadResolution(); or.candidates = list.Select(m => new Candidate(m)).ToList(); or.arguments = arguments; or.allowAdditionalArguments = allowAdditionalArguments; if (or.candidates.Count == 0) { throw new ArgumentException("at least one candidate is required"); } MemberLookupHelper.Log("OverloadResolution"); MemberLookupHelper.Log(" arguments = ", arguments); or.ConstructExpandedForms(); or.InferTypeArguments(); or.CheckApplicability(); Candidate result = or.FindBestCandidate(); MemberLookupHelper.Log("Overload resolution finished. Winning candidate = " + result); acceptableMatch = result.Status == CandidateStatus.Success; if (substituteInferredTypes) { return(result.Method); } else { return(result.OriginalMethod); } }
void Log(string text) { MemberLookupHelper.Log(text); }
void LogStep(string title) { MemberLookupHelper.Log(" candidates = ", candidates); MemberLookupHelper.Log("Overload resolution (" + title + ")"); }
static void Log(string text, IEnumerable <IReturnType> types) { MemberLookupHelper.Log(text, types); }