Type-Based Analysis for Session Inference