Пример #1
0
        internal override bool Equals(TypeSymbol t2, bool ignoreCustomModifiers, bool ignoreDynamic)
        {
            if (ReferenceEquals(this, t2))
            {
                return(true);
            }

            if ((object)t2 == null)
            {
                return(false);
            }

            CrefTypeParameterSymbol other = t2 as CrefTypeParameterSymbol;

            return((object)other != null &&
                   other.name == this.name &&
                   other.ordinal == this.ordinal &&
                   other.declaringSyntax.GetSyntax() == this.declaringSyntax.GetSyntax());
        }
        internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison)
        {
            if (ReferenceEquals(this, t2))
            {
                return(true);
            }

            if ((object)t2 == null)
            {
                return(false);
            }

            CrefTypeParameterSymbol other = t2 as CrefTypeParameterSymbol;

            return((object)other != null &&
                   other._name == _name &&
                   other._ordinal == _ordinal &&
                   other._declaringSyntax.GetSyntax() == _declaringSyntax.GetSyntax());
        }
Пример #3
0
        internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison, IReadOnlyDictionary <TypeParameterSymbol, bool> isValueTypeOverrideOpt = null)
        {
            Debug.Assert(isValueTypeOverrideOpt == null);

            if (ReferenceEquals(this, t2))
            {
                return(true);
            }

            if ((object)t2 == null)
            {
                return(false);
            }

            CrefTypeParameterSymbol other = t2 as CrefTypeParameterSymbol;

            return((object)other != null &&
                   other._name == _name &&
                   other._ordinal == _ordinal &&
                   other._declaringSyntax.GetSyntax() == _declaringSyntax.GetSyntax());
        }
        private static void AddTypeParameters(GenericNameSyntax genericNameSyntax, MultiDictionary<string, TypeParameterSymbol> map)
        {
            // NOTE: Dev11 does not warn about duplication, it just matches parameter types to the
            // *last* type parameter with the same name.  That's why we're iterating backwards and
            // skipping subsequent symbols with the same name.  This can result in some surprising
            // behavior.  For example, both 'T's in "A<T>.B<T>" bind to the second implicitly
            // declared type parameter.
            SeparatedSyntaxList<TypeSyntax> typeArguments = genericNameSyntax.TypeArgumentList.Arguments;
            for (int i = typeArguments.Count - 1; i >= 0; i--)
            {
                // Other types (non-identifiers) are allowed in error scenarios, but they do not introduce new 
                // cref type parameters.
                if (typeArguments[i].Kind() == SyntaxKind.IdentifierName)
                {
                    IdentifierNameSyntax typeParameterSyntax = (IdentifierNameSyntax)typeArguments[i];
                    Debug.Assert(typeParameterSyntax != null, "Syntactic requirement of crefs");

                    string name = typeParameterSyntax.Identifier.ValueText;
                    if (SyntaxFacts.IsValidIdentifier(name) && !map.ContainsKey(name))
                    {
                        TypeParameterSymbol typeParameterSymbol = new CrefTypeParameterSymbol(name, i, typeParameterSyntax);
                        map.Add(name, typeParameterSymbol);
                    }
                }
            }
        }