Пример #1
0
        public override IType VisitChildren(TypeVisitor visitor)
        {
            IType newBase = baseType.AcceptVisitor(visitor);

            if (newBase != baseType)
            {
                if (newBase.Nullability == Nullability.Nullable)
                {
                    // `T!` with substitution T=`U?` becomes `U?`
                    // This happens during type substitution for generic methods.
                    return(newBase);
                }
                if (newBase.Kind == TypeKind.TypeParameter || newBase.IsReferenceType == true)
                {
                    return(newBase.ChangeNullability(nullability));
                }
                else
                {
                    // `T!` with substitution T=`int` becomes `int`, not `int!`
                    return(newBase);
                }
            }
            else
            {
                return(this);
            }
        }
        public override IType VisitChildren(TypeVisitor visitor)
        {
            IType newBase = baseType.AcceptVisitor(visitor);

            if (newBase != baseType)
            {
                return(newBase.ChangeNullability(nullability));
            }
            else
            {
                return(this);
            }
        }
Пример #3
0
        public IType ChangeNullability(Nullability nullability)
        {
            IType newGenericType = genericType.ChangeNullability(nullability);

            if (newGenericType == genericType)
            {
                return(this);
            }
            else
            {
                return(new ParameterizedType(newGenericType, typeArguments));
            }
        }
Пример #4
0
        public override IType VisitChildren(TypeVisitor visitor)
        {
            IType newBase = baseType.AcceptVisitor(visitor);

            if (newBase != baseType)
            {
                if (newBase.Nullability == Nullability.Nullable)
                {
                    // T?! -> T?
                    // This happens during type substitution for generic methods.
                    return(newBase);
                }
                return(newBase.ChangeNullability(nullability));
            }
            else
            {
                return(this);
            }
        }
Пример #5
0
 public static IType WithoutNullability(this IType type)
 {
     return(type.ChangeNullability(Nullability.Oblivious));
 }