@@ -1882,7 +1882,6 @@ namespace {
18821882class MultiConformanceChecker {
18831883 ASTContext &Context;
18841884 llvm::SmallVector<ValueDecl*, 16 > UnsatisfiedReqs;
1885- llvm::SmallVector<ConformanceChecker, 4 > AllUsedCheckers;
18861885 llvm::SmallVector<NormalProtocolConformance*, 4 > AllConformances;
18871886 llvm::SmallPtrSet<ValueDecl *, 8 > CoveredMembers;
18881887
@@ -1897,13 +1896,6 @@ class MultiConformanceChecker {
18971896public:
18981897 MultiConformanceChecker (ASTContext &ctx) : Context(ctx) {}
18991898
1900- ~MultiConformanceChecker () {
1901- // Emit diagnostics at the very end.
1902- for (auto &checker : AllUsedCheckers) {
1903- emitDelayedDiags (checker.Conformance );
1904- }
1905- }
1906-
19071899 ASTContext &getASTContext () const { return Context; }
19081900
19091901 // / Add a conformance into the batched checker.
@@ -1975,7 +1967,7 @@ static void diagnoseProtocolStubFixit(
19751967 ArrayRef<ASTContext::MissingWitness> missingWitnesses);
19761968
19771969void MultiConformanceChecker::checkAllConformances () {
1978- llvm::SetVector <ASTContext::MissingWitness> MissingWitnesses;
1970+ llvm::SmallVector <ASTContext::MissingWitness, 2 > MissingWitnesses;
19791971
19801972 bool anyInvalid = false ;
19811973 for (auto *conformance : AllConformances) {
@@ -1996,11 +1988,18 @@ void MultiConformanceChecker::checkAllConformances() {
19961988 }
19971989 }
19981990
1991+ // Don't diagnose missing witnesses if we can't conform to the protocol
1992+ // at all.
1993+ if (conformance->getProtocol ()->hasMissingRequirements ()) {
1994+ assert (conformance->isInvalid ());
1995+ continue ;
1996+ }
1997+
19991998 auto LocalMissing = Context.takeDelayedMissingWitnesses (conformance);
20001999 if (LocalMissing.empty ())
20012000 continue ;
20022001
2003- MissingWitnesses.insert (LocalMissing.begin (), LocalMissing.end ());
2002+ MissingWitnesses.append (LocalMissing.begin (), LocalMissing.end ());
20042003
20052004 // Diagnose the missing witnesses.
20062005 for (auto &Missing : LocalMissing) {
@@ -2022,19 +2021,21 @@ void MultiConformanceChecker::checkAllConformances() {
20222021 }
20232022 }
20242023
2025- // If there were no missing witnesses, we're done.
2026- if (MissingWitnesses.empty ())
2027- return ;
2028-
2029- // Otherwise, backtrack to the last checker that has missing witnesses
2030- // and diagnose missing witnesses from there.
2031- for (auto *conformance : llvm::reverse (AllConformances)) {
2032- if (Context.hasDelayedConformanceErrors (conformance)) {
2033- diagnoseProtocolStubFixit (Context, conformance,
2034- MissingWitnesses.getArrayRef ());
2035- break ;
2024+ // Emit missing witness fixits for all conformances in the batch.
2025+ if (!MissingWitnesses.empty ()) {
2026+ for (auto *conformance : llvm::reverse (AllConformances)) {
2027+ if (Context.hasDelayedConformanceErrors (conformance)) {
2028+ diagnoseProtocolStubFixit (Context, conformance,
2029+ MissingWitnesses);
2030+ break ;
2031+ }
20362032 }
20372033 }
2034+
2035+ // Emit diagnostics at the very end.
2036+ for (auto *conformance : AllConformances) {
2037+ emitDelayedDiags (conformance);
2038+ }
20382039}
20392040
20402041static void diagnoseConformanceImpliedByConditionalConformance (
@@ -2404,9 +2405,8 @@ checkIndividualConformance(NormalProtocolConformance *conformance) {
24042405 if (conformance->isComplete ())
24052406 return ;
24062407
2407- // The conformance checker we're using.
2408- AllUsedCheckers.emplace_back (getASTContext (), conformance);
2409- AllUsedCheckers.back ().checkConformance ();
2408+ ConformanceChecker checker (getASTContext (), conformance);
2409+ checker.checkConformance ();
24102410}
24112411
24122412// / Add the next associated type deduction to the string representation
0 commit comments