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); } }
public IType ChangeNullability(Nullability nullability) { IType newGenericType = genericType.ChangeNullability(nullability); if (newGenericType == genericType) { return(this); } else { return(new ParameterizedType(newGenericType, typeArguments)); } }
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); } }
public static IType WithoutNullability(this IType type) { return(type.ChangeNullability(Nullability.Oblivious)); }