Make sure we don't provide duplicate synthesized conformance table entries.

This was benign with `Sendable`, but is not benign for the `Encodable`
and `Decodable` synthesis for distributed actors, which results in a
crash in TBD generation.

Fixes rdar://92008955.
This commit is contained in:
Doug Gregor
2022-04-22 15:39:57 -07:00
parent a1a8dd7de2
commit 8c3d1fb2ca
3 changed files with 19 additions and 8 deletions

View File

@@ -1532,8 +1532,16 @@ IterableDeclContext::getLocalConformances(ConformanceLookupKind lookupKind)
// Look for a Sendable conformance globally. If it is synthesized
// and matches this declaration context, use it.
auto dc = getAsGenericContext();
SmallPtrSet<ProtocolConformance *, 4> known;
for (auto conformance : findSynthesizedConformances(dc)) {
result.push_back(conformance);
// Compute the known set of conformances for the first time.
if (known.empty()) {
known.insert(result.begin(), result.end());
}
if (known.insert(conformance).second)
result.push_back(conformance);
}
break;
}