I have been doing sprint interval sessions on my bike on a trainer for about 2 years, to very good effect when I keep up with it. Last winter, I also got. Gym membership, and for about 3 months, did the same interval sessions on their gym bike with varying resistance (and tightened toe straps).
I found the fitness benefit to be similar to the bike/trainer set-up. After all, work is work. Yes, the bike fit was not as good as my bike, (it was actually more of a TT bike position with elbows resting), but I found no negative effect to real riding. I was still riding outside at least every week or two as weather allowed.
I would encourage it if that's all someone has. It can be used for Maintaining or increasing cycling fitness.