@@ -5321,40 +5321,12 @@ ASTContext::getOverrideGenericSignature(const NominalTypeDecl *baseNominal,
53215321
53225322 SmallVector<Requirement, 2 > addedRequirements;
53235323
5324- unsigned derivedDepth = 0 ;
5325- unsigned baseDepth = 0 ;
5326- if (derivedNominalSig)
5327- derivedDepth = derivedNominalSig.getGenericParams ().back ()->getDepth () + 1 ;
5328- if (const auto baseNominalSig = baseNominal->getGenericSignature ())
5329- baseDepth = baseNominalSig.getGenericParams ().back ()->getDepth () + 1 ;
5330-
5331- const auto subMap = derivedNominal->getDeclaredInterfaceType ()
5332- ->getContextSubstitutionMap (derivedNominal->getModuleContext (),
5333- baseNominal);
5334-
5335- auto substFn = [&](SubstitutableType *type) -> Type {
5336- auto *gp = cast<GenericTypeParamType>(type);
5337-
5338- if (gp->getDepth () < baseDepth) {
5339- return Type (gp).subst (subMap);
5340- }
5341-
5342- return CanGenericTypeParamType::get (
5343- gp->isTypeSequence (), gp->getDepth () - baseDepth + derivedDepth,
5344- gp->getIndex (), *this );
5345- };
5346-
5347- auto lookupConformanceFn =
5348- [&](CanType depTy, Type substTy,
5349- ProtocolDecl *proto) -> ProtocolConformanceRef {
5350- if (auto conf = subMap.lookupConformance (depTy, proto))
5351- return conf;
5352-
5353- return ProtocolConformanceRef (proto);
5354- };
5324+ OverrideSubsInfo info (baseNominal, derivedNominal,
5325+ baseGenericSig, derivedParams);
53555326
53565327 for (auto reqt : baseGenericSig.getRequirements ()) {
5357- if (auto substReqt = reqt.subst (substFn, lookupConformanceFn)) {
5328+ if (auto substReqt = reqt.subst (QueryOverrideSubs (info),
5329+ LookUpConformanceInOverrideSubs (info))) {
53585330 addedRequirements.push_back (*substReqt);
53595331 }
53605332 }
0 commit comments