/// <summary> /// Associates the given arguments with the template parameters specified in the type/method declarations /// and filters out unmatching overloads. /// </summary> /// <param name="rawOverloadList">Can be either type results or method results</param> /// <param name="givenTemplateArguments">A list of already resolved arguments passed explicitly /// in the !(...) section of a template instantiation /// or call arguments given in the (...) appendix /// that follows a method identifier</param> /// <param name="isMethodCall">If true, arguments that exceed the expected parameter count will be ignored as far as all parameters could be satisfied.</param> /// <param name="ctxt"></param> /// <returns>A filtered list of overloads which mostly fit to the specified arguments. /// Usually contains only 1 element. /// The 'TemplateParameters' property of the results will be also filled for further usage regarding smart completion etc.</returns> public static AbstractType[] DeduceParamsAndFilterOverloads(IEnumerable <AbstractType> rawOverloadList, IEnumerable <ISemantic> givenTemplateArguments, bool isMethodCall, ResolverContextStack ctxt) { if (rawOverloadList == null) { return(null); } var filteredOverloads = DeduceOverloads(rawOverloadList, givenTemplateArguments, isMethodCall, ctxt); AbstractType[] sortedAndFilteredOverloads = null; // If there are >1 overloads, filter from most to least specialized template param if (filteredOverloads.Count > 1) { sortedAndFilteredOverloads = SpecializationOrdering.FilterFromMostToLeastSpecialized(filteredOverloads, ctxt); } else if (filteredOverloads.Count == 1) { sortedAndFilteredOverloads = new[] { filteredOverloads[0] } } ; else { return(null); } if (sortedAndFilteredOverloads != null && sortedAndFilteredOverloads.Length == 1 && sortedAndFilteredOverloads[0] is TemplateType) { ImplicitTemplateProperties.TryGetImplicitProperty((TemplateType)sortedAndFilteredOverloads[0], ctxt, out sortedAndFilteredOverloads); } return(sortedAndFilteredOverloads); }