@@ -405,21 +405,15 @@ combineSubstitutionMaps(SubstitutionMap firstSubMap,
405
405
unsigned firstDepth,
406
406
unsigned secondDepth,
407
407
GenericSignature genericSig) {
408
- auto &ctx = genericSig->getASTContext ();
409
-
410
408
return SubstitutionMap::get (
411
409
genericSig,
412
410
[&](SubstitutableType *type) {
413
411
auto *gp = cast<GenericTypeParamType>(type);
414
412
if (gp->getDepth () < firstDepth)
415
413
return QuerySubstitutionMap{firstSubMap}(gp);
416
414
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);
423
417
return QuerySubstitutionMap{secondSubMap}(replacement);
424
418
},
425
419
// We might not have enough information in the substitution maps alone.
@@ -1056,16 +1050,13 @@ getWitnessMethodSubstitutions(
1056
1050
}
1057
1051
1058
1052
if (depth < baseDepth) {
1059
- paramType = GenericTypeParamType::get (paramType->getParamKind (),
1060
- depth, paramType->getIndex (), paramType->getValueType (), ctx);
1061
-
1053
+ paramType = paramType->withDepth (depth);
1062
1054
return Type (paramType).subst (baseSubMap);
1063
1055
}
1064
1056
1065
1057
depth = depth - baseDepth + 1 ;
1066
1058
1067
- paramType = GenericTypeParamType::get (paramType->getParamKind (),
1068
- depth, paramType->getIndex (), paramType->getValueType (), ctx);
1059
+ paramType = paramType->withDepth (depth);
1069
1060
return Type (paramType).subst (origSubMap);
1070
1061
},
1071
1062
[&](CanType type, Type substType, ProtocolDecl *proto) {
@@ -1084,10 +1075,8 @@ getWitnessMethodSubstitutions(
1084
1075
1085
1076
if (depth < baseDepth) {
1086
1077
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);
1091
1080
1092
1081
assert (!isa<GenericTypeParamType>(t));
1093
1082
return std::nullopt ;
@@ -1099,10 +1088,8 @@ getWitnessMethodSubstitutions(
1099
1088
depth = depth - baseDepth + 1 ;
1100
1089
1101
1090
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);
1106
1093
1107
1094
assert (!isa<GenericTypeParamType>(t));
1108
1095
return std::nullopt ;
0 commit comments