Ejemplo n.º 1
0
        static public NamedTypeSymbol AsUnboundGenericType(this NamedTypeSymbol type)
        {
            if (!type.IsGenericType)
            {
                // This exception is part of the public contract of NamedTypeSymbol.ConstructUnboundGenericType
                throw new InvalidOperationException();
            }

            var             original = type.OriginalDefinition;
            int             n        = original.Arity;
            NamedTypeSymbol originalContainingType = original.ContainingType;

            var constructedFrom = ((object)originalContainingType == null) ?
                                  original :
                                  original.AsMember(originalContainingType.IsGenericType ? originalContainingType.AsUnboundGenericType() : originalContainingType);

            if (n == 0)
            {
                return(constructedFrom);
            }

            var typeArguments = UnboundArgumentErrorTypeSymbol.CreateTypeArguments(
                constructedFrom.TypeParameters,
                n,
                new CSDiagnosticInfo(ErrorCode.ERR_UnexpectedUnboundGenericName));

            return(constructedFrom.Construct(typeArguments, unbound: true));
        }
Ejemplo n.º 2
0
        static public NamedTypeSymbol AsUnboundGenericType(this NamedTypeSymbol type)
        {
            if (!type.IsGenericType)
            {
                return(type);
            }

            var original        = type.OriginalDefinition;
            int n               = original.Arity;
            var constructedFrom = ((object)original.ContainingType == null) ?
                                  original :
                                  original.AsMember(original.ContainingType.AsUnboundGenericType());

            if (n == 0)
            {
                return(constructedFrom);
            }

            var typeArguments = UnboundArgumentErrorTypeSymbol.CreateTypeArguments(
                constructedFrom.TypeParameters,
                n,
                new CSDiagnosticInfo(ErrorCode.ERR_UnexpectedUnboundGenericName));

            return(constructedFrom.Construct(typeArguments, unbound: true));
        }
Ejemplo n.º 3
0
        internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison)
        {
            if ((object)t2 == (object)this)
            {
                return(true);
            }

            UnboundArgumentErrorTypeSymbol other = t2 as UnboundArgumentErrorTypeSymbol;

            return((object)other != null && string.Equals(other._name, _name, StringComparison.Ordinal) && object.Equals(other._errorInfo, _errorInfo));
        }
Ejemplo n.º 4
0
        internal override bool Equals(TypeSymbol t2, bool ignoreCustomModifiers, bool ignoreDynamic)
        {
            if ((object)t2 == (object)this)
            {
                return(true);
            }

            UnboundArgumentErrorTypeSymbol other = t2 as UnboundArgumentErrorTypeSymbol;

            return((object)other != null && string.Equals(other._name, _name, StringComparison.Ordinal) && object.Equals(other._errorInfo, _errorInfo));
        }
Ejemplo n.º 5
0
        internal override bool Equals(TypeSymbol t2, TypeCompareKind comparison, IReadOnlyDictionary <TypeParameterSymbol, bool> isValueTypeOverrideOpt = null)
        {
            Debug.Assert(isValueTypeOverrideOpt == null);

            if ((object)t2 == (object)this)
            {
                return(true);
            }

            UnboundArgumentErrorTypeSymbol other = t2 as UnboundArgumentErrorTypeSymbol;

            return((object)other != null && string.Equals(other._name, _name, StringComparison.Ordinal) && object.Equals(other._errorInfo, _errorInfo));
        }