Skip to content

Commit f30aa68

Browse files
committed
[IRGen] Fix witness table miscompilation.
If a foreign type conforms to a protocol, and that conformance is not resilient, we were emitting an instantantiation function but it would never be called because we weren't emitting the `GenericWitnessTable` that would have contained a reference to it. This was happening because of a missing `isSynthesizedNonUnique()` call in `isDependentConformance()`. rdar://97290618
1 parent 0cc2ee1 commit f30aa68

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/IRGen/GenProto.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -961,11 +961,13 @@ static bool isDependentConformance(
961961
if (assocConformance.isInvalid())
962962
return false;
963963

964+
auto rootConformance = assocConformance.getConcrete()->getRootConformance();
965+
966+
// [*] This condition must be true if getConformanceInfo() would return
967+
// an AccessorConformanceInfo().
964968
if (assocConformance.isAbstract() ||
965-
isDependentConformance(IGM,
966-
assocConformance.getConcrete()
967-
->getRootConformance(),
968-
visited))
969+
isSynthesizedNonUnique(rootConformance) ||
970+
isDependentConformance(IGM, rootConformance, visited))
969971
return true;
970972
}
971973

@@ -2142,6 +2144,9 @@ IRGenModule::getConformanceInfo(const ProtocolDecl *protocol,
21422144
// so in theory we could allocate them on a BumpPtrAllocator. But there's not
21432145
// a good one for us to use. (The ASTContext's outlives the IRGenModule in
21442146
// batch mode.)
2147+
//
2148+
// N.B. If you change this condition, you may need to update the condition
2149+
// marked [*] in isDependentConformance().
21452150
if (isDependentConformance(rootConformance) ||
21462151
// Foreign types need to go through the accessor to unique the witness
21472152
// table.

0 commit comments

Comments
 (0)