@@ -3318,57 +3318,36 @@ void ConformanceChecker::ensureRequirementsAreSatisfied(
3318
3318
= Conformance->populateSignatureConformances ();
3319
3319
3320
3320
class GatherConformancesListener : public GenericRequirementsCheckListener {
3321
- TypeChecker &tc;
3322
3321
NormalProtocolConformance *conformance;
3323
3322
std::function<void (ProtocolConformanceRef)> &writer;
3324
3323
public:
3325
3324
GatherConformancesListener (
3326
- TypeChecker &tc,
3327
- NormalProtocolConformance *conformance,
3328
- std::function<void (ProtocolConformanceRef)> &writer)
3329
- : tc(tc), conformance(conformance), writer(writer) { }
3325
+ NormalProtocolConformance *conformance,
3326
+ std::function<void (ProtocolConformanceRef)> &writer)
3327
+ : conformance(conformance), writer(writer) { }
3330
3328
3331
3329
void satisfiedConformance (Type depTy, Type replacementTy,
3332
3330
ProtocolConformanceRef conformance) override {
3333
3331
// The conformance will use contextual types, but we want the
3334
3332
// interface type equivalent.
3335
-
3336
- // If we have an inherited conformance for an archetype, dig out the
3337
- // superclass conformance to translate.
3338
- Type inheritedInterfaceType;
3339
3333
if (conformance.isConcrete () &&
3340
3334
conformance.getConcrete ()->getType ()->hasArchetype ()) {
3341
3335
auto concreteConformance = conformance.getConcrete ();
3342
- if (concreteConformance->getKind ()
3343
- == ProtocolConformanceKind::Inherited &&
3344
- conformance.getConcrete ()->getType ()->is <ArchetypeType>()) {
3345
- inheritedInterfaceType =
3346
- concreteConformance->getType ()->mapTypeOutOfContext ();
3347
- concreteConformance =
3348
- cast<InheritedProtocolConformance>(concreteConformance)
3349
- ->getInheritedConformance ();
3350
- }
3351
3336
3352
3337
// Map the conformance.
3353
- // FIXME: It would be so much easier and efficient if we had
3354
- // ProtocolConformance::mapTypesOutOfContext().
3355
3338
auto interfaceType =
3356
3339
concreteConformance->getType ()->mapTypeOutOfContext ();
3357
3340
3358
- conformance = *tc.conformsToProtocol (
3359
- interfaceType,
3360
- conformance.getRequirement (),
3361
- this ->conformance ->getDeclContext (),
3362
- (ConformanceCheckFlags::SuppressDependencyTracking|
3363
- ConformanceCheckFlags::SkipConditionalRequirements));
3341
+ concreteConformance = concreteConformance->subst (
3342
+ interfaceType,
3343
+ [](SubstitutableType *type) -> Type {
3344
+ if (auto *archetypeType = type->getAs <ArchetypeType>())
3345
+ return archetypeType->getInterfaceType ();
3346
+ return type;
3347
+ },
3348
+ MakeAbstractConformanceForGenericType ());
3364
3349
3365
- // Reinstate inherited conformance.
3366
- if (inheritedInterfaceType) {
3367
- conformance =
3368
- ProtocolConformanceRef (
3369
- tc.Context .getInheritedConformance (inheritedInterfaceType,
3370
- conformance.getConcrete ()));
3371
- }
3350
+ conformance = ProtocolConformanceRef (concreteConformance);
3372
3351
}
3373
3352
3374
3353
writer (conformance);
@@ -3384,7 +3363,7 @@ void ConformanceChecker::ensureRequirementsAreSatisfied(
3384
3363
3385
3364
return false ;
3386
3365
}
3387
- } listener (TC, Conformance, writer);
3366
+ } listener (Conformance, writer);
3388
3367
3389
3368
auto result = TC.checkGenericArguments (
3390
3369
DC, Loc, Loc,
0 commit comments