It uses the appropriate method for the generic function predict().
In your case it is predict.ar(), and you can examine it by
> getS3method("predict", "ar")
On Tue, 15 Jul 2003, ATHANASIA KAMARIOTIS wrote:
> Can you please tell me how R computes : " predict(ar.x)$pred "
> in :
> 
> #let x be a vector
> 
> ar.x<-ar(x)
> predict(ar.x)$pred
-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595