Don't forget that Beorn's animal friends are still about, and they apparently
report Bilbo's incautious words to Beorn, for he teases Bilbo about it the next
morning. Rather than explaining all this to Bilbo, and risk even ruder
words from Bilbo, Gandalf just hushes him up and sends him off to bed.
Not all dreams are prophetic. In this case I think Bilbo just dreams of
what Gandalf told him about. Although what he hears during the night is
real
enough.
“I dislike Allegory - the conscious and intentional allegory - yet any attempt to explain the purport of myth or fairytale must use allegorical language. (And, of course, the more 'life' a story has the more readily will it be susceptible of allegorical interpretations: while the better a deliberate allegory is made the more nearly will it be acceptable just as a story.)” (From Tolkien Letter # 131.)