The metabolism really slows down a lot during the night, so if you eat a lot before bed the surplus will likely be stored as fat. On the other hand, it is good idea to eat something before bed (some protein and fat) to give the body some nutrients during that time and avoid catabolism. Fat will slows down the absortion of protein, and protein hopefully will help to create a positive nitrogen balance. (certains bodybuilders even wake up at the middle of night to ingest protein). Cottage cheese, casein based proteins, egg whites, some flax seed oil, peanut butter or some other fat sources would be good for that.
Also, and asking your question, if you don't eat above your caloric needs even if you ate a whole meal before bed (disregarding the fact that it woudn't help digestion i guess to go with a large stomach to bed) i don't think you would gain fat...but that's not advisable.