@@ -405,21 +405,15 @@ combineSubstitutionMaps(SubstitutionMap firstSubMap,
405405 unsigned firstDepth,
406406 unsigned secondDepth,
407407 GenericSignature genericSig) {
408- auto &ctx = genericSig->getASTContext ();
409-
410408 return SubstitutionMap::get (
411409 genericSig,
412410 [&](SubstitutableType *type) {
413411 auto *gp = cast<GenericTypeParamType>(type);
414412 if (gp->getDepth () < firstDepth)
415413 return QuerySubstitutionMap{firstSubMap}(gp);
416414
417- auto *replacement = GenericTypeParamType::get (
418- gp->getParamKind (),
419- gp->getDepth () + secondDepth - firstDepth,
420- gp->getIndex (),
421- gp->getValueType (),
422- ctx);
415+ auto *replacement = gp->withDepth (
416+ gp->getDepth () + secondDepth - firstDepth);
423417 return QuerySubstitutionMap{secondSubMap}(replacement);
424418 },
425419 // We might not have enough information in the substitution maps alone.
@@ -1056,16 +1050,13 @@ getWitnessMethodSubstitutions(
10561050 }
10571051
10581052 if (depth < baseDepth) {
1059- paramType = GenericTypeParamType::get (paramType->getParamKind (),
1060- depth, paramType->getIndex (), paramType->getValueType (), ctx);
1061-
1053+ paramType = paramType->withDepth (depth);
10621054 return Type (paramType).subst (baseSubMap);
10631055 }
10641056
10651057 depth = depth - baseDepth + 1 ;
10661058
1067- paramType = GenericTypeParamType::get (paramType->getParamKind (),
1068- depth, paramType->getIndex (), paramType->getValueType (), ctx);
1059+ paramType = paramType->withDepth (depth);
10691060 return Type (paramType).subst (origSubMap);
10701061 },
10711062 [&](CanType type, Type substType, ProtocolDecl *proto) {
@@ -1084,10 +1075,8 @@ getWitnessMethodSubstitutions(
10841075
10851076 if (depth < baseDepth) {
10861077 type = CanType (type.transformRec ([&](TypeBase *t) -> std::optional<Type> {
1087- if (t == paramType) {
1088- return Type (GenericTypeParamType::get (paramType->getParamKind (),
1089- depth, paramType->getIndex (), paramType->getValueType (), ctx));
1090- }
1078+ if (t == paramType)
1079+ return paramType->withDepth (depth);
10911080
10921081 assert (!isa<GenericTypeParamType>(t));
10931082 return std::nullopt ;
@@ -1099,10 +1088,8 @@ getWitnessMethodSubstitutions(
10991088 depth = depth - baseDepth + 1 ;
11001089
11011090 type = CanType (type.transformRec ([&](TypeBase *t) -> std::optional<Type> {
1102- if (t == paramType) {
1103- return Type (GenericTypeParamType::get (paramType->getParamKind (),
1104- depth, paramType->getIndex (), paramType->getValueType (), ctx));
1105- }
1091+ if (t == paramType)
1092+ return paramType->withDepth (depth);
11061093
11071094 assert (!isa<GenericTypeParamType>(t));
11081095 return std::nullopt ;
0 commit comments