[NFC] Separate Taking Redundant Conformance Diagnostics From The Lookup Table

This commit is contained in:
Robert Widmann
2020-03-24 12:40:11 -07:00
parent 7811f531cb
commit a9e11e3130
7 changed files with 57 additions and 38 deletions

View File

@@ -1327,17 +1327,15 @@ NominalTypeDecl::getSatisfiedProtocolRequirementsForMember(
}
SmallVector<ProtocolDecl *, 2>
DeclContext::getLocalProtocols(
ConformanceLookupKind lookupKind,
SmallVectorImpl<ConformanceDiagnostic> *diagnostics) const
{
DeclContext::getLocalProtocols(ConformanceLookupKind lookupKind) const {
SmallVector<ProtocolDecl *, 2> result;
// Dig out the nominal type.
NominalTypeDecl *nominal = getSelfNominalTypeDecl();
if (!nominal)
if (!nominal) {
return result;
}
// Update to record all potential conformances.
nominal->prepareConformanceTable();
nominal->ConformanceTable->lookupConformances(
@@ -1346,22 +1344,20 @@ DeclContext::getLocalProtocols(
lookupKind,
&result,
nullptr,
diagnostics);
nullptr);
return result;
}
SmallVector<ProtocolConformance *, 2>
DeclContext::getLocalConformances(
ConformanceLookupKind lookupKind,
SmallVectorImpl<ConformanceDiagnostic> *diagnostics) const
{
DeclContext::getLocalConformances(ConformanceLookupKind lookupKind) const {
SmallVector<ProtocolConformance *, 2> result;
// Dig out the nominal type.
NominalTypeDecl *nominal = getSelfNominalTypeDecl();
if (!nominal)
if (!nominal) {
return result;
}
// Protocols only have self-conformances.
if (auto protocol = dyn_cast<ProtocolDecl>(nominal)) {
@@ -1378,7 +1374,35 @@ DeclContext::getLocalConformances(
lookupKind,
nullptr,
&result,
diagnostics);
nullptr);
return result;
}
SmallVector<ConformanceDiagnostic, 4>
DeclContext::takeConformanceDiagnostics() const {
SmallVector<ConformanceDiagnostic, 4> result;
// Dig out the nominal type.
NominalTypeDecl *nominal = getSelfNominalTypeDecl();
if (!nominal) {
return { };
}
// Protocols are not subject to the checks for supersession.
if (isa<ProtocolDecl>(nominal)) {
return { };
}
// Update to record all potential conformances.
nominal->prepareConformanceTable();
nominal->ConformanceTable->lookupConformances(
nominal,
const_cast<DeclContext *>(this),
ConformanceLookupKind::All,
nullptr,
nullptr,
&result);
return result;
}