- | isMetaTyVar tv = do { untch <- getUntouchables
- ; return (inTouchableRange untch tv) }
- | otherwise = return False
+ = case tcTyVarDetails tv of
+ MetaTv TcsTv _ -> return True -- See Note [Touchable meta type variables]
+ MetaTv {} -> do { untch <- getUntouchables
+ ; return (inTouchableRange untch tv) }
+ _ -> return False
+\end{code}
+
+Note [Touchable meta type variables]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Meta type variables allocated *by the constraint solver itself* are always
+touchable. Example:
+ instance C a b => D [a] where...
+if we use this instance declaration we "make up" a fresh meta type
+variable for 'b', which we must later guess. (Perhaps C has a
+functional dependency.) But since we aren't in the constraint *generator*
+we can't allocate a Unique in the touchable range for this implication
+constraint. Instead, we mark it as a "TcsTv", which makes it always-touchable.