@@ -291,48 +291,6 @@ GenericEnvironment::getMappingIfPresent(GenericParamKey key) const {
291291 return std::nullopt ;
292292}
293293
294- namespace {
295-
296- // / Substitute the outer generic parameters from a substitution map, ignoring
297- // / innter generic parameters with a given depth.
298- struct SubstituteOuterFromSubstitutionMap {
299- SubstitutionMap subs;
300- unsigned depth;
301-
302- // / Whether this is a type parameter that should not be substituted.
303- bool isUnsubstitutedTypeParameter (Type type) const {
304- if (!type->isTypeParameter ())
305- return false ;
306-
307- if (auto depMemTy = type->getAs <DependentMemberType>())
308- return isUnsubstitutedTypeParameter (depMemTy->getBase ());
309-
310- if (auto genericParam = type->getAs <GenericTypeParamType>())
311- return genericParam->getDepth () >= depth;
312-
313- return false ;
314- }
315-
316- Type operator ()(SubstitutableType *type) const {
317- if (isUnsubstitutedTypeParameter (type))
318- return Type (type);
319-
320- return QuerySubstitutionMap{subs}(type);
321- }
322-
323- ProtocolConformanceRef operator ()(CanType dependentType,
324- Type conformingReplacementType,
325- ProtocolDecl *conformedProtocol) const {
326- if (isUnsubstitutedTypeParameter (dependentType))
327- return ProtocolConformanceRef (conformedProtocol);
328-
329- return LookUpConformanceInSubstitutionMap (subs)(
330- dependentType, conformingReplacementType, conformedProtocol);
331- }
332- };
333-
334- }
335-
336294Type
337295GenericEnvironment::maybeApplyOuterContextSubstitutions (Type type) const {
338296 switch (getKind ()) {
@@ -342,10 +300,8 @@ GenericEnvironment::maybeApplyOuterContextSubstitutions(Type type) const {
342300
343301 case Kind::OpenedElement:
344302 case Kind::Opaque: {
345- auto packElements = getGenericSignature ().getInnermostGenericParams ();
346- auto elementDepth = packElements.front ()->getDepth ();
347- SubstituteOuterFromSubstitutionMap replacer{
348- getOuterSubstitutions (), elementDepth};
303+ OuterSubstitutions replacer{
304+ getOuterSubstitutions (), getGenericSignature ()->getMaxDepth ()};
349305 return type.subst (replacer, replacer);
350306 }
351307 }
0 commit comments