[ty] More type-variable default validation (#23639)
## Summary
We have several checks at the moment which fire on legacy type variables
with invalid defaults in a _class_ context, but which fail to check for
legacy type variables with invalid defaults in a _function_ context.
This PR adds those missing checks.
The typing spec states that both legacy and PEP-695 type variables are
not allowed to have defaults that:
- reference type variables bound in outer scopes, or
- reference type variables that are put into scope later on in the type
parameter list or function signature
The typing spec also states that a type variable with a default is not
allowed to come before any type variables without defaults.
## Test Plan
mdtests and snapshots