hmm. A bit of the old chicken and egg dilemma : a melody on prescribed chords, or chords on a described melody ?
And, btw, playing a melody somewhere in a song is something else than playing the main theme.
In that case 'melody' should be seen as a 'solo' fragment, based on the current circumstances.