Could the solution to that problem be to go toy shopping with your child in tow? This isn't always possible, without making an unpleasant scene for example, but if it is possible then I'd have thought it should be tried. Of course children shouldn't always be given what they want unconditionally, that just leads to spoilt brats, but if the young boy were able to choose between two toys of the same price and picked "the girls' one" then I can't see any reason for that wish not to be granted. And if they get bored of it later then, well, maybe there is a lesson in that for them not to make snap decisions.
The best way I'd have thought of putting it is that if a child expresses a particular wish for a toy that is not typically associated with their gender then it shouldn't be dismissed as "you can't play with that, it's a girls' toy" (or vice versa).
My Mum, who has worked in a creche for pretty much my entire lifetime, tells me that this sort of thing rarely comes up anyway, and without encouragement young girls tend to go for the dolls etc whereas boys rush for the cars (although what went on at the children's homes is anyone's guess). When it does come up, though, the worst thing that can be done is surely to discourage the child from playing with the toys they prefer and forcing toys they don't want upon them.
This works the other way, of course -- it would be equally wrong to suggest to a boy that he should play with a doll if he's not shown any interest in it, just to show yourself as a parent capable of challenging traditional gender roles.