This is an example of the literary device known as foreshadowing (emphasis mine):
Foreshadowing or guessing ahead is a literary device by which an author hints what is to come. Foreshadowing is a dramatic device in which an important plot-point is mentioned early in the story and will return in a more significant way. It is used to avoid disappointment. It is also sometimes used to arouse the reader.
A hint that is designed to mislead the audience is referred to as a red herring. A similar device is the flashforward (also known as prolepsis). However, foreshadowing only hints at a possible outcome within the confinement of a narrative. A flashforward is a scene that takes the narrative forward in time from the current point of the story in literature, film, television, and other media. Foreshadowing is sometimes employed through characters explicitly predicting the future.
Note that foreshadowing of a revelation does not necessarily require a statement that that revelation will be true; it could just as easily be a red herring statement that that revelation will be false, as in this case. One of my favourite examples of this in the HP series is the following extract from book 6:
"I'd love to know what Snape told him to convince him," said Tonks.
"I know," said Harry, and they all turned to look at him. "Snape passed Voldemort the information that made Voldemort hunt down my mum and dad. Then Snape told Dumbledore he hadn't realised what he was doing, he was really sorry he'd done it, sorry that they were dead."
They all stared at him.
"And Dumbledore believed that?" said Lupin incredulously. "Dumbledore believed Snape was sorry James was dead? Snape hated James..."
"And he didn't think my mother was worth a damn either," said Harry, "because she was Muggle-born...'Mudblood,' he calld her..."
-- HP and the Half-Blood Prince, Chapter 29: The Phoenix Lament (emphasis mine)
In the first case, a character makes a statement which the characters and readers assume at that point to be obviously false but which later turns out to be true; in the second, the characters and readers assume the statement to be true but it later turns out to be false. In both cases, there is foreshadowing but also, in hindsight, irony.
In-universe, of course, the characters making the statements have no idea of the revelations to come, so there would still be irony in hindsight (assuming they remembered making these statements) but not deliberate foreshadowing.