-Wterm-variable-capture fires where it should not
## Summary
In my MR !10385 @torsten.schmits gave the [code](https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10385#note_500256) example that should work according to the scoping, but it doesn't with my changes. Then I understand, that `-Wterm-variable-capture` suffers from the same problem.
## Steps to reproduce
```haskell
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wterm-variable-capture #-}
module T where
import GHC.Types (Type)
k = 12
class C k a where
type AT a :: k -> Type
```
Will output the warning:
```
T.hs:10:16: warning: [GHC-54201] [-Wterm-variable-capture]
The type variable ‘k’ is implicitly quantified,
even though another variable of the same name is in scope:
‘k’ defined at T.hs:7:1
This is not forward-compatible with a planned GHC extension, RequiredTypeArguments.
Suggested fix: Consider renaming the type variable.
|
10 | type AT a :: k -> Type
| ^
```
## Expected behavior
No warning should be produced, since `k` is bounded at type class head and this code doesn't produce the warning:
```haskell
{-# OPTIONS_GHC -Wterm-variable-capture #-}
module T where
k = 12
id :: forall k . k -> k
id a = a
```
## Environment
* GHC version used: master branch
issue