@@ -845,6 +845,11 @@ void ASTBuilder::pushGenericParams(ArrayRef<std::pair<unsigned, unsigned>> param
845845void ASTBuilder::popGenericParams () {
846846 ParameterPacks = ParameterPackStack.back ();
847847 ParameterPackStack.pop_back ();
848+
849+ if (!ValueParametersStack.empty ()) {
850+ ValueParameters = ValueParametersStack.back ();
851+ ValueParametersStack.pop_back ();
852+ }
848853}
849854
850855Type ASTBuilder::createGenericTypeParameterType (unsigned depth,
@@ -857,6 +862,17 @@ Type ASTBuilder::createGenericTypeParameterType(unsigned depth,
857862 }
858863 }
859864
865+ if (!ValueParameters.empty ()) {
866+ for (auto tuple : ValueParameters) {
867+ auto pair = std::get<std::pair<unsigned , unsigned >>(tuple);
868+ auto type = std::get<Type>(tuple);
869+
870+ if (pair.first == depth && pair.second == index) {
871+ return GenericTypeParamType::getValue (depth, index, type, Ctx);
872+ }
873+ }
874+ }
875+
860876 return GenericTypeParamType::getType (depth, index, Ctx);
861877}
862878
@@ -1197,9 +1213,18 @@ CanGenericSignature ASTBuilder::demangleGenericSignature(
11971213 // we introduce the parameter packs from the nominal's generic signature.
11981214 ParameterPackStack.push_back (ParameterPacks);
11991215 ParameterPacks.clear ();
1216+
1217+ ValueParametersStack.push_back (ValueParameters);
1218+ ValueParameters.clear ();
12001219 for (auto *paramTy : baseGenericSig.getGenericParams ()) {
12011220 if (paramTy->isParameterPack ())
12021221 ParameterPacks.emplace_back (paramTy->getDepth (), paramTy->getIndex ());
1222+
1223+ if (paramTy->isValue ()) {
1224+ auto pair = std::make_pair (paramTy->getDepth (), paramTy->getIndex ());
1225+ auto tuple = std::make_tuple (pair, paramTy->getValueType ());
1226+ ValueParameters.emplace_back (tuple);
1227+ }
12031228 }
12041229 SWIFT_DEFER { popGenericParams (); };
12051230
0 commit comments