Skip to content

Commit 2973e3f

Browse files
committed
Sema: Remove ConformanceChecker::SuppressDiagnostics
1 parent 415b7bc commit 2973e3f

File tree

2 files changed

+12
-41
lines changed

2 files changed

+12
-41
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 11 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,7 +1853,6 @@ class swift::MultiConformanceChecker {
18531853
if (checker.AlreadyComplained)
18541854
continue;
18551855

1856-
checker.SuppressDiagnostics = false; // no need to restore to prev value
18571856
checker.emitDelayedDiags();
18581857
}
18591858
}
@@ -2116,8 +2115,7 @@ checkIndividualConformance(NormalProtocolConformance *conformance,
21162115
// conformance is invalid for other reasons, so emit diagnosis now.
21172116
if (revivedMissingWitnesses.empty()) {
21182117
// Emit any delayed diagnostics.
2119-
ConformanceChecker(getASTContext(), conformance, MissingWitnesses,
2120-
false)
2118+
ConformanceChecker(getASTContext(), conformance, MissingWitnesses)
21212119
.emitDelayedDiags();
21222120
}
21232121
}
@@ -2908,14 +2906,12 @@ diagnoseMatch(ModuleDecl *module, NormalProtocolConformance *conformance,
29082906

29092907
ConformanceChecker::ConformanceChecker(
29102908
ASTContext &ctx, NormalProtocolConformance *conformance,
2911-
llvm::SetVector<MissingWitness> &GlobalMissingWitnesses,
2912-
bool suppressDiagnostics)
2909+
llvm::SetVector<MissingWitness> &GlobalMissingWitnesses)
29132910
: WitnessChecker(ctx, conformance->getProtocol(), conformance->getType(),
29142911
conformance->getDeclContext()),
29152912
Conformance(conformance), Loc(conformance->getLoc()),
29162913
GlobalMissingWitnesses(GlobalMissingWitnesses),
2917-
LocalMissingWitnessesStartIndex(GlobalMissingWitnesses.size()),
2918-
SuppressDiagnostics(suppressDiagnostics) {}
2914+
LocalMissingWitnessesStartIndex(GlobalMissingWitnesses.size()) {}
29192915

29202916
ConformanceChecker::~ConformanceChecker() {}
29212917

@@ -5485,9 +5481,6 @@ void ConformanceChecker::checkConformance(MissingWitnessDiagnosisKind Kind) {
54855481
FrontendStatsTracer statsTracer(getASTContext().Stats,
54865482
"check-conformance", Conformance);
54875483

5488-
llvm::SaveAndRestore<bool> restoreSuppressDiagnostics(SuppressDiagnostics);
5489-
SuppressDiagnostics = false;
5490-
54915484
// FIXME: Caller checks that this type conforms to all of the
54925485
// inherited protocols.
54935486

@@ -5503,12 +5496,12 @@ void ConformanceChecker::checkConformance(MissingWitnessDiagnosisKind Kind) {
55035496
// Resolve all of the type witnesses.
55045497
resolveTypeWitnesses();
55055498

5506-
// Check the requirements from the requirement signature.
5507-
ensureRequirementsAreSatisfied();
5508-
55095499
// Diagnose missing type witnesses for now.
55105500
diagnoseMissingWitnesses(Kind, /*Delayed=*/false);
55115501

5502+
// Check the requirements from the requirement signature.
5503+
ensureRequirementsAreSatisfied();
5504+
55125505
// Check non-type requirements.
55135506
resolveValueWitnesses();
55145507

@@ -5539,10 +5532,6 @@ void ConformanceChecker::checkConformance(MissingWitnessDiagnosisKind Kind) {
55395532
}
55405533
}
55415534
}
5542-
5543-
if (Conformance->isInvalid()) {
5544-
return;
5545-
}
55465535
}
55475536

55485537
/// Retrieve the Objective-C method key from the given function.
@@ -5725,29 +5714,17 @@ void ConformanceChecker::diagnoseOrDefer(
57255714
if (isError)
57265715
Conformance->setInvalid();
57275716

5728-
if (SuppressDiagnostics) {
5729-
// Stash this in the ASTContext for later emission.
5730-
auto conformance = Conformance;
5731-
5732-
getASTContext().addDelayedConformanceDiag(
5733-
conformance,
5734-
{requirement, [conformance, fn] { fn(conformance); }, isError});
5735-
return;
5736-
}
5737-
5738-
// Complain that the type does not conform, once.
5739-
if (isError && !AlreadyComplained) {
5740-
diagnoseConformanceFailure(Adoptee, Proto, DC, Loc);
5741-
AlreadyComplained = true;
5742-
}
5717+
// Stash this in the ASTContext for later emission.
5718+
auto conformance = Conformance;
57435719

5744-
fn(Conformance);
5720+
getASTContext().addDelayedConformanceDiag(
5721+
conformance,
5722+
{requirement, [conformance, fn] { fn(conformance); }, isError});
57455723
}
57465724

57475725
void ConformanceChecker::emitDelayedDiags() {
57485726
auto diags = getASTContext().takeDelayedConformanceDiags(Conformance);
57495727

5750-
assert(!SuppressDiagnostics && "Should not be suppressing diagnostics now");
57515728
for (const auto &diag: diags) {
57525729
// Complain that the type does not conform, once.
57535730
if (diag.IsError && !AlreadyComplained) {

lib/Sema/TypeCheckProtocol.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -787,11 +787,6 @@ class ConformanceChecker : public WitnessChecker {
787787
/// this protocol under checking.
788788
unsigned LocalMissingWitnessesStartIndex;
789789

790-
/// True if we shouldn't complain about problems with this conformance
791-
/// right now, i.e. if methods are being called outside
792-
/// checkConformance().
793-
bool SuppressDiagnostics;
794-
795790
/// Whether we've already complained about problems with this conformance.
796791
bool AlreadyComplained = false;
797792

@@ -896,8 +891,7 @@ class ConformanceChecker : public WitnessChecker {
896891
void emitDelayedDiags();
897892

898893
ConformanceChecker(ASTContext &ctx, NormalProtocolConformance *conformance,
899-
llvm::SetVector<MissingWitness> &GlobalMissingWitnesses,
900-
bool suppressDiagnostics = true);
894+
llvm::SetVector<MissingWitness> &GlobalMissingWitnesses);
901895

902896
~ConformanceChecker();
903897

0 commit comments

Comments
 (0)