As noted in the comments, it's very difficult to define a \smashoperator command that deals with all possible cases involving long limits. To understand why it is difficult, you need to know a little about boxes in TeX. Roughly speaking, horizontally smashed boxes (the limits in this case) are considered to have zero width, and there is no easy way to say
Small objects should consider the
limits to be smashed, but large
objects should
not.
which is what you need.
The following code seems to work in your case, but will probably fail in others that I have not considered. In my opinion it would be better to avoid long limits, because they are grotesque (perhaps this is why the author(s) of mathtools did not provide an easy way to construct them).
\documentclass{minimal}
\usepackage{mathtools}
\newcommand{\test}[4]{ %
%
\newbox\bigbox
\newbox\smallbox
\newbox\argbox
\newdimen\smallwidth
\newdimen\offsetwidth
\newdimen\argwidth
%
%Store the unsmashed operator in \bigbox.
\sbox\bigbox{\ensuremath{\displaystyle #1_{#2}^{#3}}}
%Now store the smashed operator in \smallbox.
\sbox\smallbox{\ensuremath{\smashoperator{#1_{#2}^{#3}}}}
%Finally, store the argument in \argbox
\sbox\argbox{\ensuremath{\displaystyle \,#4}}
%Calculate the width of the argument
\argwidth=\wd\argbox
%
%Calculate the width by which the limits protrude. Note:
%this will evaluate to zero if the limits do not protrude.
\offsetwidth=\wd\bigbox
\smallwidth=\wd\smallbox
\multiply\smallwidth by -1
\advance\offsetwidth by \smallwidth
\divide\offsetwidth by 2
%
%Place the unsmashed operator and the argument on the page,
%pulling back the argument by the appropriate distance.
\usebox\bigbox\hspace{-\offsetwidth}\usebox\argbox
%
%If the width of the argument is less than the width of
%the protrusion, we now need to add some more space.
\ifnum\offsetwidth>\argwidth \hspace{\offsetwidth}\hspace{-\argwidth} \fi
%
}
\begin{document}
\begin{equation*}
\left[\test{\bigcup}{longlimit}{longlimit}{f(x)} \right]
\quad
\left[\test{\bigcup}{veryverylonglimit}{veryverylonglimit}{f(x)} \right]
\quad
\left[\test{\bigcup}{x}{y}{f(x)} \right]
\end{equation*}
\end{document}
\smashoperatordoes precisely what it should do here. What result did you expect? (Maybe try\smashoperator[r]?) – Andrey Vihrov Apr 8 '11 at 12:09\smashoperatorknow there is a fence behind it? – daleif Apr 8 '11 at 15:30\smashoperatordoes not fit. – daleif Apr 8 '11 at 16:09