properly deal with unification in type patterns (closes #2776)