4. Given $-1<a<0,|x-a|=a^{2}$. Then the range of values for $x$ is ( ).
(A) $-1<x<0$
(B) $0<x<1$
(C) $-2<x<0$
(D) $0<x<2$
4.C.

From the problem, we know that $x \neq a$.
When $x > a$, we get $x - a = a^2$, which means $x = a^2 + a$.
When $-1 < a < 0$, we have $-\frac{1}{4} < x < 0$.
When $x < a$, we get $a - x = a^2$, which means $x = -a^2 + a$.
When $-1 < a < 0$, we have $-2 < x < 0$.
In summary, we get $-2 < x < 0$.