diff --git a/mypy/types.py b/mypy/types.py
--- a/mypy/types.py
+++ b/mypy/types.py
@@ -2760,6 +2760,7 @@ def get_proper_types(
     TypeTranslator as TypeTranslator,
     TypeVisitor as TypeVisitor,
 )
+from mypy.typetraverser import TypeTraverserVisitor
 
 
 class TypeStrVisitor(SyntheticTypeVisitor[str]):
@@ -3122,6 +3123,18 @@ def visit_type_var(self, typ: TypeVarType) -> Type:
         return typ
 
 
+class LocationSetter(TypeTraverserVisitor):
+    # TODO: Should we update locations of other Type subclasses?
+    def __init__(self, line: int, column: int) -> None:
+        self.line = line
+        self.column = column
+
+    def visit_instance(self, typ: Instance) -> None:
+        typ.line = self.line
+        typ.column = self.column
+        super().visit_instance(typ)
+
+
 def replace_alias_tvars(
     tp: Type, vars: List[str], subs: List[Type], newline: int, newcolumn: int
 ) -> Type:
@@ -3130,6 +3143,7 @@ def replace_alias_tvars(
     """
     replacer = InstantiateAliasVisitor(vars, subs)
     new_tp = tp.accept(replacer)
+    new_tp.accept(LocationSetter(newline, newcolumn))
     new_tp.line = newline
     new_tp.column = newcolumn
     return new_tp

diff --git a/test-data/unit/check-generics.test b/test-data/unit/check-generics.test
--- a/test-data/unit/check-generics.test
+++ b/test-data/unit/check-generics.test
@@ -648,6 +648,30 @@ reveal_type(f3()) # N: Revealed type is "Union[builtins.int, __main__.Node[built
 
 [builtins fixtures/list.pyi]
 
+[case testGenericTypeAliasesWithNestedArgs]
+# flags: --pretty --show-error-codes
+import other
+a: other.Array[float]
+reveal_type(a) # N: Revealed type is "other.array[Any, other.dtype[builtins.float]]"
+
+[out]
+main:3: error: Type argument "float" of "dtype" must be a subtype of "generic"  [type-var]
+    a: other.Array[float]
+       ^
+[file other.py]
+from typing import Any, Generic, TypeVar
+
+DT = TypeVar("DT", covariant=True, bound=dtype[Any])
+DTS = TypeVar("DTS", covariant=True, bound=generic)
+S = TypeVar("S", bound=Any)
+ST = TypeVar("ST", bound=generic, covariant=True)
+
+class common: pass
+class generic(common): pass
+class dtype(Generic[DTS]): pass
+class array(common, Generic[S, DT]): pass
+Array = array[Any, dtype[ST]]
+
 [case testGenericTypeAliasesAny]
 from typing import TypeVar, Generic
 T = TypeVar('T')

Can not find "numpy.core._multiarray_umath" if numpy is installed via pip with --target argument.
<!--
  If you're new to mypy and you're not sure whether what you're experiencing is a mypy bug, please see the "Question and Help" form
  instead.
  Please also consider:

  - checking our common issues page: https://mypy.readthedocs.io/en/stable/common_issues.html
  - searching our issue tracker: https://github.com/python/mypy/issues to see if
    it's already been reported
  - asking on gitter chat: https://gitter.im/python/typing
-->

**Bug Report**

<!--
Note: If the problem you are reporting is about a specific library function, then the typeshed tracker is better suited
for this report: https://github.com/python/typeshed/issues
-->


When `numpy` is installed with a non-user or a non-system directory the is specified in `MYPYPATH` path mypy fails with some missing modules.

**To Reproduce**


1. `python3 -m pip install --user mypy`
2. `python3 -m pip install --target=$HOME/tmp/site-packages numpy`
3.
```
cat > $HOME/tmp/test.py <<EOF
from typing import Any, TYPE_CHECKING
import numpy as np
import numpy.typing as npt

a: npt.NDArray[Any] = np.ndarray((2,3))
if TYPE_CHECKING:
    reveal_type(a)
EOF
````
4. `MYPYPATH=$HOME/tmp/site-packages python3 -m mypy $HOME/tmp/test.py`
```
tmp/site-packages/numpy/core/umath.py:10: error: Cannot find implementation or library stub for module named "numpy.core._multiarray_umath"
tmp/site-packages/numpy/core/umath.py:10: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
tmp/site-packages/numpy/typing/_generic_alias.py:66: error: "object" has no attribute "__parameters__"
...
tmp/site-packages/numpy/typing/_ufunc.pyi:2937: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
tmp/site-packages/numpy/typing/_ufunc.pyi:3034: error: Class numpy.flexible has abstract attributes "__init__"
tmp/site-packages/numpy/typing/_ufunc.pyi:3034: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
tmp/site-packages/numpy/typing/_ufunc.pyi:3060: error: Class numpy.character has abstract attributes "__init__"
tmp/site-packages/numpy/typing/_ufunc.pyi:3060: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
Found 166 errors in 21 files (checked 1 source file)
```

**Expected Behavior**

<!--
  How did you expect your project to behave?
  It’s fine if you’re not sure your understanding is correct.
  Write down what you thought would happen. If you just expected no errors, you can delete this section.
-->

I would expect that mypy at step 4 works similar to 
```
python3 -m pip install --user numpy
python3 -m mypy $HOME/tmp/test.py
tmp/test.py:7: note: Revealed type is "numpy.ndarray[Any, numpy.dtype[Any]]"
```

**Actual Behavior**

<!--
  Did something go wrong?
  Is something broken, or not behaving as you expected?
-->

```
MYPYPATH=$HOME/tmp/site-packages python3 -m mypy $HOME/tmp/test.py
tmp/site-packages/numpy/core/umath.py:10: error: Cannot find implementation or library stub for module named "numpy.core._multiarray_umath"
tmp/site-packages/numpy/core/umath.py:10: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
tmp/site-packages/numpy/typing/_generic_alias.py:66: error: "object" has no attribute "__parameters__"
tmp/site-packages/numpy/typing/_generic_alias.py:67: error: Value of type "object" is not indexable
tmp/site-packages/numpy/typing/_generic_alias.py:170: error: Argument 2 to "_reconstruct_alias" has incompatible type "Iterator[object]"; expected "Iterator[TypeVar]"
tmp/site-packages/numpy/typing/_add_docstring.py:38: error: Need type annotation for "new_lines" (hint: "new_lines: List[<type>] = ...")
tmp/site-packages/numpy/lib/polynomial.pyi:59: error: Overloaded function signatures 1 and 2 overlap with incompatible return types
tmp/site-packages/numpy/lib/polynomial.pyi:59: error: Overloaded function signatures 1 and 3 overlap with incompatible return types
...
tmp/site-packages/numpy/typing/_ufunc.pyi:3034: error: Class numpy.flexible has abstract attributes "__init__"
tmp/site-packages/numpy/typing/_ufunc.pyi:3034: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
tmp/site-packages/numpy/typing/_ufunc.pyi:3060: error: Class numpy.character has abstract attributes "__init__"
tmp/site-packages/numpy/typing/_ufunc.pyi:3060: note: If it is meant to be abstract, add 'abc.ABCMeta' as an explicit metaclass
Found 166 errors in 21 files (checked 1 source file)
```

**Your Environment**

<!-- Include as many relevant details about the environment you experienced the bug in -->

- Mypy version used: 0.942
- Mypy command-line flags: `MYPYPATH=$HOME/tmp/site-packages mypy $HOME/tmp/test.py`
- Mypy configuration options from `mypy.ini` (and other config files): --
- Python version used: 3.8.10
- Operating system and version: Ubuntu 20.04


mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testMultipleGenericTypeParametersWithMethods mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeApplicationArgTypes mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testOperatorAssignmentWithIndexLvalue2 mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericMethodReturnType mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testMultipleGenericTypeParametersAndSubtyping mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeApplicationArgTypesSubclasses mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testNestedGenericTypes mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericMethodArgument mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeBody1 mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeApplicationAlias mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeCheckingGenericFunctionBody mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericMemberVariable mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeApplicationCrash mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeBodyWithMultipleVariables mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeCheckingGenericMethodBody mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testCompatibilityOfNoneWithTypeVar mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesBasic mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testProhibitTypeApplicationToGenericFunctions mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericMemberVariable2 mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testCompatibilityOfTypeVarWithObject mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeApplicationArgs mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSimpleGenericSubtyping mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesBasic2 mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericOperations mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeApplicationTvars mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testInvalidTypeApplicationType mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeCompatibilityWithAny mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testOperatorAssignmentWithIndexLvalue1 mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesWrongAliases mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesRuntimeExpressionsInstance mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeVariableAsTypeArgument mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesForAliases mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testMultipleGenericTypeParametersWithMemberVars mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesRuntimeExpressionsOther mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesPEPBasedExample mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSimplifiedGenericSimple mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesTypeVarBinding mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSimplifiedGenericCallable mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesImporting mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesTypeVarConstraints mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesIgnoredPotentialAlias mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSimplifiedGenericComplex mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesImportingWithoutTypeVar mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testNoSubscriptionOfBuiltinAliases mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSimplifiedGenericOrder mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesImportingWithoutTypeVarError mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesAny mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSimplifiedGenericDuplicate mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testImportedTypeAliasInRuntimeContext mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericAliasWithTypeVarsFromDifferentModules mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSimplifiedGenericNotAll mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesAcessingMethods mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSimplifiedGenericInvalid mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeAliasesResultingInPlainInstance mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testMultipleAssignmentWithLists mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testErrorWithShorterGenericTypeName mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesSubclassing mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testAliasesInClassBodyNormalVsSubscripted mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testMultipleAssignmentWithListsInInitialization mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testErrorWithShorterGenericTypeName2 mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testClassLevelTypeVariable mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesSubclassingBad mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testMultipleAssignmentWithListAndIndexing mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericInnerClass mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericArgumentInOverload mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassInnerFunctionTypeVariable mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testMultipleAssignmentWithIterable mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesUnion mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericFunctionAsOverloadItem mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassInsideOtherGenericClass mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testErrorWithLongGenericTypeName mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesTuple mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testLocalTypeVariable mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSubtypingGenericTypeObject mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSubtypingWithGenericFunctions mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testIdentityHigherOrderFunction mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesCallable mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeVariableTypeIs mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testIdentityHigherOrderFunction2 mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSubtypingWithGenericInnerFunctions mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeVariableUnionAndCallableInTypeInference mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testIdentityHigherOrderFunction3 mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSubtypingWithGenericFunctionUsingTypevarWithValues mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericFunctionsWithUnalignedIds mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeVarLessThan mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testClassMethodInClassWithGenericConstructor mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSubtypingWithGenericFunctionUsingTypevarWithValues2 mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeVarReversibleOperator mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericOperatorMethodOverlapping mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeVarReversibleOperatorTuple mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeVariableTypeEquality mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericOperatorMethodOverlapping2 mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testTypeVariableWithContainerAndTuple mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassMethodSimple mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testCallTypeTWithGenericBound mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testConstraintInferenceForAnyAgainstTypeT mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testClassMethodInGenericClassWithGenericConstructorArg mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassMethodExpansion mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testQualifiedTypeVariableName mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassMethodUnboundOnClass mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassUnrelatedVars mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassMethodExpansionReplacingTypeVar mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testPartiallyQualifiedTypeVariableName mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassMethodUnboundOnSubClass mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassInGenericFunction mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassDirectCall mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassAlternativeConstructorPrecise mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassClsNonGeneric mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testNoGenericAccessOnImplicitAttributes mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassAlternativeConstructorPrecise2 mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassAttrUnboundOnClass mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassAlternativeConstructorPreciseOverloaded mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassMethodUnboundOnClassNonMatchingIdNonGeneric mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassAttrUnboundOnSubClass mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassMethodOverloaded mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassMethodAnnotation mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassMethodAnnotationDecorator mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassMethodInGenericFunction mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testMultipleAssignmentFromAnyIterable mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSubclassingGenericSelfClassMethod mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSubclassingGenericSelfClassMethodOptional mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testSubclassingGenericSelfClassMethodNonAnnotated mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericFunctionAliasExpand mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testAbstractGenericMethodInference mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericFunctionMemberExpand mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericClassPropertyBound mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericJoinRecursiveTypes mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericJoinContravariant mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericJoinRecursiveInvariant mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericJoinCovariant mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testOverlappingTypeVarIds mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericJoinNestedInvariantAny mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testConstrainedGenericSuper
mypy/test/testcheck.py::TypeCheckSuite::check-generics.test::testGenericTypeAliasesWithNestedArgs