It's the biggest cliché and cop-out in all of narrative fiction — the protagonist has a mind-boggling experience, and in the end they wake up, as the whole adventure has been a dream. The Wizard of Oz pulled off this trick, but that film is so popular and well-known that to try the "it was all a dream" again feels like a ripoff, in addition to being underwhelming to audiences. Nevertheless, filmmakers may still have that plot twist in mind, and they just go about in a very subtle way. That's the heart of a film theory surrounding the 2002 sci-fi smash Minority Report, based on a short story by genre master Philip K. Dick.
Tom Cruise stars as Chief John Anderton, part of a future police unit that can arrest murderers before they murder, thanks to the psychic, prophetic visions of "Precogs." Anderton's life is thrown into disarray when he himself is accused of a murder that hasn't happened yet. He's placed into a virtual reality prison, essentially a dream, and a guard quips, "They say your life flashes before your eyes, that all your dreams come true." Then Anderton breaks out of his VR jail, defeats the real villain, and has a happy ending. Or not — one fan theory states that Anderton never emerged from his dreamlike virtual reality state. All of his dreams came true, just like the guard predicted and clearly stated... but just not for real.