@@ -291,48 +291,6 @@ GenericEnvironment::getMappingIfPresent(GenericParamKey key) const {
291
291
return std::nullopt ;
292
292
}
293
293
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
-
336
294
Type
337
295
GenericEnvironment::maybeApplyOuterContextSubstitutions (Type type) const {
338
296
switch (getKind ()) {
@@ -342,10 +300,8 @@ GenericEnvironment::maybeApplyOuterContextSubstitutions(Type type) const {
342
300
343
301
case Kind::OpenedElement:
344
302
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 ()};
349
305
return type.subst (replacer, replacer);
350
306
}
351
307
}
0 commit comments