Phases of wave functions and level repulsion