@@ -7012,16 +7012,17 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
7012
7012
Printer << " each " ;
7013
7013
}
7014
7014
7015
- void printArchetypeCommon (Type interfaceTy, ArchetypeType *archetypeTy ) {
7015
+ void printArchetypeCommon (Type interfaceTy, GenericEnvironment *env ) {
7016
7016
if (auto *paramTy = interfaceTy->getAs <GenericTypeParamType>()) {
7017
- assert (archetypeTy->isRoot ());
7018
-
7019
7017
if (Options.AlternativeTypeNames ) {
7020
- auto found = Options.AlternativeTypeNames ->find (CanType (archetypeTy));
7021
- if (found != Options.AlternativeTypeNames ->end ()) {
7022
- if (paramTy->isParameterPack ()) printEach ();
7023
- Printer << found->second .str ();
7024
- return ;
7018
+ auto archetypeTy = env->mapTypeIntoContext (paramTy)->getAs <GenericTypeParamType>();
7019
+ if (archetypeTy) {
7020
+ auto found = Options.AlternativeTypeNames ->find (CanType (archetypeTy));
7021
+ if (found != Options.AlternativeTypeNames ->end ()) {
7022
+ if (paramTy->isParameterPack ()) printEach ();
7023
+ Printer << found->second .str ();
7024
+ return ;
7025
+ }
7025
7026
}
7026
7027
}
7027
7028
@@ -7030,18 +7031,18 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
7030
7031
}
7031
7032
7032
7033
auto *memberTy = interfaceTy->castTo <DependentMemberType>();
7033
- if (memberTy->getBase ()->is <GenericTypeParamType>())
7034
- visitParentType (archetypeTy-> getRoot ( ));
7034
+ if (auto *paramTy = memberTy->getBase ()->getAs <GenericTypeParamType>())
7035
+ visitParentType (env-> mapTypeIntoContext (paramTy ));
7035
7036
else {
7036
- printArchetypeCommon (memberTy->getBase (), archetypeTy-> getRoot () );
7037
+ printArchetypeCommon (memberTy->getBase (), env );
7037
7038
Printer << " ." ;
7038
7039
}
7039
7040
7040
7041
printDependentMember (memberTy);
7041
7042
}
7042
7043
7043
7044
void visitPrimaryArchetypeType (PrimaryArchetypeType *T) {
7044
- printArchetypeCommon (T->getInterfaceType (), T);
7045
+ printArchetypeCommon (T->getInterfaceType (), T-> getGenericEnvironment () );
7045
7046
}
7046
7047
7047
7048
void visitOpaqueTypeArchetypeType (OpaqueTypeArchetypeType *T) {
@@ -7050,7 +7051,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
7050
7051
7051
7052
if (!paramTy) {
7052
7053
assert (interfaceTy->is <DependentMemberType>());
7053
- printArchetypeCommon (interfaceTy, T);
7054
+ printArchetypeCommon (interfaceTy, T-> getGenericEnvironment () );
7054
7055
return ;
7055
7056
}
7056
7057
@@ -7135,7 +7136,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
7135
7136
}
7136
7137
7137
7138
void visitPackArchetypeType (PackArchetypeType *T) {
7138
- printArchetypeCommon (T->getInterfaceType (), T);
7139
+ printArchetypeCommon (T->getInterfaceType (), T-> getGenericEnvironment () );
7139
7140
}
7140
7141
7141
7142
void visitGenericTypeParamType (GenericTypeParamType *T) {
0 commit comments