Merge pull request #83776 from hamishknight/the-diags-never-stop-no

[Diags] Allow multiple in-flight diagnostics
This commit is contained in:
Hamish Knight
2025-09-03 19:59:44 +01:00
committed by GitHub
27 changed files with 150 additions and 139 deletions

View File

@@ -1928,7 +1928,6 @@ bool MissingOptionalUnwrapFailure::diagnoseAsError() {
"#default value#"
"> }");
}
diag.flush();
offerDefaultValueUnwrapFixIt(varDecl->getDeclContext(), initializer);
offerForceUnwrapFixIt(initializer);
@@ -3155,7 +3154,7 @@ void ContextualFailure::tryFixIts(InFlightDiagnostic &diagnostic) const {
if (tryIntegerCastFixIts(diagnostic))
return;
if (tryProtocolConformanceFixIt(diagnostic))
if (tryProtocolConformanceFixIt())
return;
if (tryTypeCoercionFixIt(diagnostic))
@@ -3526,8 +3525,7 @@ bool ContextualFailure::tryTypeCoercionFixIt(
return false;
}
bool ContextualFailure::tryProtocolConformanceFixIt(
InFlightDiagnostic &diagnostic) const {
bool ContextualFailure::tryProtocolConformanceFixIt() const {
auto innermostTyCtx = getDC()->getInnermostTypeContext();
if (!innermostTyCtx)
return false;
@@ -3561,8 +3559,6 @@ bool ContextualFailure::tryProtocolConformanceFixIt(
if (!shouldOfferFixIt)
return false;
diagnostic.flush();
// Let's build a list of protocols that the context does not conform to.
SmallVector<std::string, 8> missingProtoTypeStrings;
SmallVector<ProtocolDecl *, 8> missingProtocols;
@@ -4095,7 +4091,6 @@ bool SubscriptMisuseFailure::diagnoseAsError() {
} else {
diag.fixItReplace(SourceRange(memberExpr->getDotLoc(), memberExpr->getLoc()), "[<#index#>]");
}
diag.flush();
if (auto overload = getOverloadChoiceIfAvailable(locator)) {
emitDiagnosticAt(overload->choice.getDecl(), diag::kind_declared_here,
@@ -5360,8 +5355,6 @@ bool MissingArgumentsFailure::diagnoseAsError() {
diag.fixItInsertAfter(getRawAnchor().getEndLoc(), fixIt.str());
}
diag.flush();
if (auto selectedOverload = getCalleeOverloadChoiceIfAvailable(locator)) {
if (auto *decl = selectedOverload->choice.getDeclOrNull()) {
emitDiagnosticAt(decl, diag::decl_declared_here, decl);
@@ -5729,8 +5722,6 @@ bool MissingArgumentsFailure::diagnoseInvalidTupleDestructuring() const {
diagnostic.fixItRemove(TE->getLParenLoc()).fixItRemove(TE->getRParenLoc());
}
diagnostic.flush();
// Add a note which points to the overload choice location.
emitDiagnosticAt(decl, diag::decl_declared_here, decl);
return true;
@@ -6131,8 +6122,6 @@ bool ExtraneousArgumentsFailure::diagnoseAsError() {
}
}
diag.flush();
// If all of the parameters are anonymous, let's point out references
// to make it explicit where parameters are used in complex closure body,
// which helps in situations where braces are missing for potential inner
@@ -8633,8 +8622,6 @@ void MissingRawRepresentableInitFailure::fixIt(
.fixItInsert(range.Start, rawReprObjType->getString() + "(rawValue: ")
.fixItInsertAfter(range.End, ")");
} else if (valueObjType) {
diagnostic.flush();
std::string fixItBefore = RawReprType->getString() + "(rawValue: ";
std::string fixItAfter;