Let $X$ be a smooth scheme of finite type over an algebraically closed field of characteristic zero and with a trivial class group $Cl(X)=0$. Let $Y$ be a dense open subscheme of $X$ such that: 


1) $Y$ is a quasi-affine scheme s.t. $\Gamma(\mathcal{O}\_Y,Y)$ is of finite type; and 


2) $X \setminus Y$ is irreducible of codimension at least two. 


Does these conditions imply that $X$ is itself a quasi-affine scheme? If not, can anyone provide a counter-example please?


Thank you in advance!



Conditions for a smooth scheme of finite type with trivial class group to be quasi-affine
Here is a counterexample. Unfortunately it is not separated, so I don't know how interesting it is to you.


Consider $X = \mathbf{A}^2 \cup \mathbf{A}^2$, glued along $\mathbf{A}^2 \setminus \{(0,0)\}$, and let $Y$ be one copy of $\mathbf{A}^2$. $X$ is not quasi-affine since it is not separated. $\operatorname{Cl}(X) \cong \operatorname{Cl}(Y) = 0$ since the complement of $Y$ in $X$ is a point, which has codimension 2. Also, $Y$ is affine, and $\Gamma(Y,\mathcal{O}\_Y) = k[x,y]$ is of finite type.


Finally, some remarks which I commented earlier:


1. [Schröer](http://doi.org/10.1007/s002290050203) has an example of a complete *normal* variety with $\operatorname{Pic}X = 0$, but I didn't compute its class group since you wanted a smooth example.
2. [Hamm and Lê](http://www.emis.de/journals/SC/2005/10/pdf/smf_sem-cong_10_71-86.pdf) show that a complex algebraic variety with $H^1 = H^2 = 0$ (the actual condition is weaker) would have trivial class group, so this might be a place where you could find a counterexample that is also a variety.


