@@ -1882,7 +1882,6 @@ namespace {
1882
1882
class MultiConformanceChecker {
1883
1883
ASTContext &Context;
1884
1884
llvm::SmallVector<ValueDecl*, 16 > UnsatisfiedReqs;
1885
- llvm::SmallVector<ConformanceChecker, 4 > AllUsedCheckers;
1886
1885
llvm::SmallVector<NormalProtocolConformance*, 4 > AllConformances;
1887
1886
llvm::SmallPtrSet<ValueDecl *, 8 > CoveredMembers;
1888
1887
@@ -1897,13 +1896,6 @@ class MultiConformanceChecker {
1897
1896
public:
1898
1897
MultiConformanceChecker (ASTContext &ctx) : Context(ctx) {}
1899
1898
1900
- ~MultiConformanceChecker () {
1901
- // Emit diagnostics at the very end.
1902
- for (auto &checker : AllUsedCheckers) {
1903
- emitDelayedDiags (checker.Conformance );
1904
- }
1905
- }
1906
-
1907
1899
ASTContext &getASTContext () const { return Context; }
1908
1900
1909
1901
// / Add a conformance into the batched checker.
@@ -1975,7 +1967,7 @@ static void diagnoseProtocolStubFixit(
1975
1967
ArrayRef<ASTContext::MissingWitness> missingWitnesses);
1976
1968
1977
1969
void MultiConformanceChecker::checkAllConformances () {
1978
- llvm::SetVector <ASTContext::MissingWitness> MissingWitnesses;
1970
+ llvm::SmallVector <ASTContext::MissingWitness, 2 > MissingWitnesses;
1979
1971
1980
1972
bool anyInvalid = false ;
1981
1973
for (auto *conformance : AllConformances) {
@@ -1996,11 +1988,18 @@ void MultiConformanceChecker::checkAllConformances() {
1996
1988
}
1997
1989
}
1998
1990
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
+
1999
1998
auto LocalMissing = Context.takeDelayedMissingWitnesses (conformance);
2000
1999
if (LocalMissing.empty ())
2001
2000
continue ;
2002
2001
2003
- MissingWitnesses.insert (LocalMissing.begin (), LocalMissing.end ());
2002
+ MissingWitnesses.append (LocalMissing.begin (), LocalMissing.end ());
2004
2003
2005
2004
// Diagnose the missing witnesses.
2006
2005
for (auto &Missing : LocalMissing) {
@@ -2022,19 +2021,21 @@ void MultiConformanceChecker::checkAllConformances() {
2022
2021
}
2023
2022
}
2024
2023
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
+ }
2036
2032
}
2037
2033
}
2034
+
2035
+ // Emit diagnostics at the very end.
2036
+ for (auto *conformance : AllConformances) {
2037
+ emitDelayedDiags (conformance);
2038
+ }
2038
2039
}
2039
2040
2040
2041
static void diagnoseConformanceImpliedByConditionalConformance (
@@ -2404,9 +2405,8 @@ checkIndividualConformance(NormalProtocolConformance *conformance) {
2404
2405
if (conformance->isComplete ())
2405
2406
return ;
2406
2407
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 ();
2410
2410
}
2411
2411
2412
2412
// / Add the next associated type deduction to the string representation
0 commit comments