Skip to content

Commit 7c21789

Browse files
committed
SILGen: Unwrap inherited conformance when emitting witness thunk
I'm about to fix RequirementEnvironment to correctly use inherited conformances.
1 parent 53e52ab commit 7c21789

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/SILGen/SILGenType.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,15 @@ SILFunction *SILGenModule::emitProtocolWitness(
797797
}
798798
}
799799

800+
ProtocolConformance *manglingConformance = nullptr;
801+
if (conformance.isConcrete()) {
802+
manglingConformance = conformance.getConcrete();
803+
if (auto *inherited = dyn_cast<InheritedProtocolConformance>(manglingConformance)) {
804+
manglingConformance = inherited->getInheritedConformance();
805+
conformance = ProtocolConformanceRef(manglingConformance);
806+
}
807+
}
808+
800809
// Lower the witness thunk type with the requirement's abstraction level.
801810
auto witnessSILFnType = getNativeSILFunctionType(
802811
M.Types, TypeExpansionContext::minimal(), AbstractionPattern(reqtOrigTy),
@@ -805,8 +814,6 @@ SILFunction *SILGenModule::emitProtocolWitness(
805814

806815
// Mangle the name of the witness thunk.
807816
Mangle::ASTMangler NewMangler;
808-
auto manglingConformance =
809-
conformance.isConcrete() ? conformance.getConcrete() : nullptr;
810817
std::string nameBuffer =
811818
NewMangler.mangleWitnessThunk(manglingConformance, requirement.getDecl());
812819
// TODO(TF-685): Proper mangling for derivative witness thunks.

0 commit comments

Comments
 (0)