@@ -3290,57 +3290,36 @@ void ConformanceChecker::ensureRequirementsAreSatisfied(
3290
3290
= Conformance->populateSignatureConformances ();
3291
3291
3292
3292
class GatherConformancesListener : public GenericRequirementsCheckListener {
3293
- TypeChecker &tc;
3294
3293
NormalProtocolConformance *conformance;
3295
3294
std::function<void (ProtocolConformanceRef)> &writer;
3296
3295
public:
3297
3296
GatherConformancesListener (
3298
- TypeChecker &tc,
3299
- NormalProtocolConformance *conformance,
3300
- std::function<void (ProtocolConformanceRef)> &writer)
3301
- : tc(tc), conformance(conformance), writer(writer) { }
3297
+ NormalProtocolConformance *conformance,
3298
+ std::function<void (ProtocolConformanceRef)> &writer)
3299
+ : conformance(conformance), writer(writer) { }
3302
3300
3303
3301
void satisfiedConformance (Type depTy, Type replacementTy,
3304
3302
ProtocolConformanceRef conformance) override {
3305
3303
// The conformance will use contextual types, but we want the
3306
3304
// interface type equivalent.
3307
-
3308
- // If we have an inherited conformance for an archetype, dig out the
3309
- // superclass conformance to translate.
3310
- Type inheritedInterfaceType;
3311
3305
if (conformance.isConcrete () &&
3312
3306
conformance.getConcrete ()->getType ()->hasArchetype ()) {
3313
3307
auto concreteConformance = conformance.getConcrete ();
3314
- if (concreteConformance->getKind ()
3315
- == ProtocolConformanceKind::Inherited &&
3316
- conformance.getConcrete ()->getType ()->is <ArchetypeType>()) {
3317
- inheritedInterfaceType =
3318
- concreteConformance->getType ()->mapTypeOutOfContext ();
3319
- concreteConformance =
3320
- cast<InheritedProtocolConformance>(concreteConformance)
3321
- ->getInheritedConformance ();
3322
- }
3323
3308
3324
3309
// Map the conformance.
3325
- // FIXME: It would be so much easier and efficient if we had
3326
- // ProtocolConformance::mapTypesOutOfContext().
3327
3310
auto interfaceType =
3328
3311
concreteConformance->getType ()->mapTypeOutOfContext ();
3329
3312
3330
- conformance = *tc.conformsToProtocol (
3331
- interfaceType,
3332
- conformance.getRequirement (),
3333
- this ->conformance ->getDeclContext (),
3334
- (ConformanceCheckFlags::SuppressDependencyTracking|
3335
- ConformanceCheckFlags::SkipConditionalRequirements));
3313
+ concreteConformance = concreteConformance->subst (
3314
+ interfaceType,
3315
+ [](SubstitutableType *type) -> Type {
3316
+ if (auto *archetypeType = type->getAs <ArchetypeType>())
3317
+ return archetypeType->getInterfaceType ();
3318
+ return type;
3319
+ },
3320
+ MakeAbstractConformanceForGenericType ());
3336
3321
3337
- // Reinstate inherited conformance.
3338
- if (inheritedInterfaceType) {
3339
- conformance =
3340
- ProtocolConformanceRef (
3341
- tc.Context .getInheritedConformance (inheritedInterfaceType,
3342
- conformance.getConcrete ()));
3343
- }
3322
+ conformance = ProtocolConformanceRef (concreteConformance);
3344
3323
}
3345
3324
3346
3325
writer (conformance);
@@ -3356,7 +3335,7 @@ void ConformanceChecker::ensureRequirementsAreSatisfied(
3356
3335
3357
3336
return false ;
3358
3337
}
3359
- } listener (TC, Conformance, writer);
3338
+ } listener (Conformance, writer);
3360
3339
3361
3340
auto result = TC.checkGenericArguments (
3362
3341
DC, Loc, Loc,
0 commit comments