Boo.Lang.Compiler.TypeSystem.Generics.GenericsServices.ConstructAmbiguousEntity C# (CSharp) Метод

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

Validates and constructs generic entities out of an ambiguous generic definition entity.
private ConstructAmbiguousEntity ( Node constructionNode, Ambiguous ambiguousDefinition, IType typeArguments ) : IEntity
constructionNode Node
ambiguousDefinition Ambiguous
typeArguments IType
Результат IEntity
        private IEntity ConstructAmbiguousEntity(Node constructionNode, Ambiguous ambiguousDefinition, IType[] typeArguments)
        {
            var checker = new GenericConstructionChecker(typeArguments, constructionNode);
            var matches = new List<IEntity>(ambiguousDefinition.Entities);
            bool reportErrors = false;
            foreach (Predicate<IEntity> check in checker.Checks)
            {
                matches = matches.Collect(check);

                if (matches.Count == 0)
                {
                    Errors.Add(checker.Errors[0]); // only report first error, assuming the rest are superfluous
                    return TypeSystemServices.ErrorEntity;
                }

                if (reportErrors)
                    checker.ReportErrors(Errors);

                checker.DiscardErrors();

                // We only want full error reporting once we get down to a single candidate
                if (matches.Count == 1)
                    reportErrors = true;
            }

            IEntity[] constructedMatches = Array.ConvertAll<IEntity, IEntity>(matches.ToArray(), def => MakeGenericEntity(def, typeArguments));
            return Entities.EntityFromList(constructedMatches);
        }