@@ -5447,15 +5447,42 @@ void ConformanceChecker::ensureRequirementsAreSatisfied() {
5447
5447
ProtocolConformanceRef conformance) override {
5448
5448
// The conformance will use contextual types, but we want the
5449
5449
// interface type equivalent.
5450
+
5451
+ // If we have an inherited conformance for an archetype, dig out the
5452
+ // superclass conformance to translate.
5453
+ Type inheritedInterfaceType;
5450
5454
if (conformance.isConcrete () &&
5451
5455
conformance.getConcrete ()->getType ()->hasArchetype ()) {
5456
+ auto concreteConformance = conformance.getConcrete ();
5457
+ if (concreteConformance->getKind ()
5458
+ == ProtocolConformanceKind::Inherited &&
5459
+ conformance.getConcrete ()->getType ()->is <ArchetypeType>()) {
5460
+ inheritedInterfaceType =
5461
+ concreteConformance->getType ()->mapTypeOutOfContext ();
5462
+ concreteConformance =
5463
+ cast<InheritedProtocolConformance>(concreteConformance)
5464
+ ->getInheritedConformance ();
5465
+ }
5466
+
5467
+ // Map the conformance.
5468
+ // FIXME: It would be so much easier and efficient if we had
5469
+ // ProtocolConformance::mapTypesOutOfContext().
5452
5470
auto interfaceType =
5453
- conformance.getConcrete ()->getType ()->mapTypeOutOfContext ();
5471
+ concreteConformance->getType ()->mapTypeOutOfContext ();
5472
+
5454
5473
conformance = *tc.conformsToProtocol (
5455
- interfaceType,
5456
- conformance.getRequirement (),
5457
- dc,
5458
- ConformanceCheckFlags::SuppressDependencyTracking);
5474
+ interfaceType,
5475
+ conformance.getRequirement (),
5476
+ dc,
5477
+ ConformanceCheckFlags::SuppressDependencyTracking);
5478
+
5479
+ // Reinstate inherited conformance.
5480
+ if (inheritedInterfaceType) {
5481
+ conformance =
5482
+ ProtocolConformanceRef (
5483
+ tc.Context .getInheritedConformance (inheritedInterfaceType,
5484
+ conformance.getConcrete ()));
5485
+ }
5459
5486
}
5460
5487
5461
5488
writer (conformance);
0 commit comments