@@ -1607,7 +1607,8 @@ void MultiConformanceChecker::checkAllConformances() {
1607
1607
for (auto It = AllUsedCheckers.rbegin (); It != AllUsedCheckers.rend ();
1608
1608
++It) {
1609
1609
if (!It->getLocalMissingWitness ().empty ()) {
1610
- It->diagnoseMissingWitnesses (MissingWitnessDiagnosisKind::FixItOnly);
1610
+ if (It->diagnoseMissingWitnesses (MissingWitnessDiagnosisKind::FixItOnly))
1611
+ break ;
1611
1612
}
1612
1613
}
1613
1614
}
@@ -3099,13 +3100,30 @@ filterProtocolRequirements(
3099
3100
return Filtered;
3100
3101
}
3101
3102
3102
- void ConformanceChecker::
3103
+ bool ConformanceChecker::
3103
3104
diagnoseMissingWitnesses (MissingWitnessDiagnosisKind Kind) {
3104
3105
auto LocalMissing = getLocalMissingWitness ();
3105
3106
3106
3107
// If this conformance has nothing to complain, return.
3107
3108
if (LocalMissing.empty ())
3108
- return ;
3109
+ return false ;
3110
+
3111
+ // Diagnose the missing witnesses.
3112
+ for (auto &Missing : LocalMissing) {
3113
+ auto requirement = Missing.requirement ;
3114
+ auto matches = Missing.matches ;
3115
+ auto nominal = Adoptee->getAnyNominal ();
3116
+ diagnoseOrDefer (requirement, true ,
3117
+ [requirement, matches, nominal](NormalProtocolConformance *conformance) {
3118
+ auto dc = conformance->getDeclContext ();
3119
+ auto *protocol = conformance->getProtocol ();
3120
+ // Possibly diagnose reason for automatic derivation failure
3121
+ DerivedConformance::tryDiagnoseFailedDerivation (dc, nominal, protocol);
3122
+ // Diagnose each of the matches.
3123
+ for (const auto &match : matches)
3124
+ diagnoseMatch (dc->getParentModule (), conformance, requirement, match);
3125
+ });
3126
+ }
3109
3127
3110
3128
const auto InsertFixit = [](
3111
3129
NormalProtocolConformance *Conf, SourceLoc ComplainLoc, bool EditorMode,
@@ -3226,19 +3244,19 @@ diagnoseMissingWitnesses(MissingWitnessDiagnosisKind Kind) {
3226
3244
});
3227
3245
}
3228
3246
clearGlobalMissingWitnesses ();
3229
- return ;
3247
+ return true ;
3230
3248
}
3231
3249
case MissingWitnessDiagnosisKind::ErrorOnly: {
3232
3250
diagnoseOrDefer (
3233
3251
LocalMissing[0 ].requirement , true , [](NormalProtocolConformance *) {});
3234
- return ;
3252
+ return true ;
3235
3253
}
3236
3254
case MissingWitnessDiagnosisKind::FixItOnly:
3237
3255
InsertFixit (Conformance, Loc, IsEditorMode,
3238
3256
filterProtocolRequirements (GlobalMissingWitnesses.getArrayRef (),
3239
3257
Adoptee));
3240
3258
clearGlobalMissingWitnesses ();
3241
- return ;
3259
+ return true ;
3242
3260
}
3243
3261
}
3244
3262
@@ -3744,17 +3762,7 @@ ConformanceChecker::resolveWitnessViaLookup(ValueDecl *requirement) {
3744
3762
if (!numViable) {
3745
3763
// Save the missing requirement for later diagnosis.
3746
3764
GlobalMissingWitnesses.insert ({requirement, matches});
3747
- diagnoseOrDefer (requirement, true ,
3748
- [requirement, matches, nominal](NormalProtocolConformance *conformance) {
3749
- auto dc = conformance->getDeclContext ();
3750
- auto *protocol = conformance->getProtocol ();
3751
- // Possibly diagnose reason for automatic derivation failure
3752
- DerivedConformance::tryDiagnoseFailedDerivation (dc, nominal, protocol);
3753
- // Diagnose each of the matches.
3754
- for (const auto &match : matches)
3755
- diagnoseMatch (dc->getParentModule (), conformance, requirement, match);
3756
- });
3757
- return ResolveWitnessResult::ExplicitFailed;
3765
+ return ResolveWitnessResult::Missing;
3758
3766
}
3759
3767
3760
3768
diagnoseOrDefer (requirement, true ,
0 commit comments