The previous version did not substitute the type used in the scrutinee. (cherry picked from commit 9b719549)