That's true, Arwen Imladris; but I doubt that Sam would've known of the conversation. It seems unlikely that Gandalf would've spoken later of what happened, except maybe to convince Frodo of the power of the Ring. In which case I don't think Frodo would've felt the need to tell Sam about it, certainly not down to the very exact words. Still, you never know

.