Embedded: support existentials with inherited conformances

That means: derived classes where the base conforms to a protocol
This commit is contained in:
Erik Eckstein
2024-10-04 20:55:23 +02:00
parent 54e7cdda25
commit a3e6e86383
7 changed files with 116 additions and 4 deletions

View File

@@ -2504,10 +2504,14 @@ IRGenModule::getConformanceInfo(const ProtocolDecl *protocol,
const ConformanceInfo *info;
auto *specConf = conformance;
if (auto *inheritedC = dyn_cast<InheritedProtocolConformance>(conformance))
specConf = inheritedC->getInheritedConformance();
// If there is a specialized SILWitnessTable for the specialized conformance,
// directly use it.
if (auto *sc = dyn_cast<SpecializedProtocolConformance>(conformance)) {
SILWitnessTable *wt = getSILModule().lookUpWitnessTable(conformance);
if (auto *sc = dyn_cast<SpecializedProtocolConformance>(specConf)) {
SILWitnessTable *wt = getSILModule().lookUpWitnessTable(specConf);
if (wt && wt->getConformance() == sc) {
info = new SpecializedConformanceInfo(sc);
Conformances.try_emplace(conformance, info);