mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Add DiagGroupID to Diagnostic
This change addresses the following issue: when an error is being wrapped in a warning, the diagnostic message will use the wrapper's `DiagGroupID` as the warning's name. However, we want to retain the original error's group for use. For example, in Swift 5, async_unavailable_decl is wrapped in error_in_future_swift_version. When we print a diagnostic of this kind, we want to keep the `DiagGroupID` of `async_unavailable_decl`, not that of `error_in_future_swift_version`. To achieve this, we add `DiagGroupID` to the `Diagnostic` class. When an active diagnostic is wrapped in DiagnosticEngine, we retain the original `DiagGroupID`. For illustration purposes, this change also introduces a new group: `DeclarationUnavailableFromAsynchronousContext`. With this change, we produce errors and warnings of this kind with messages like the following: ``` global function 'fNoAsync' is unavailable from asynchronous contexts [DeclarationUnavailableFromAsynchronousContext] global function 'fNoAsync' is unavailable from asynchronous contexts; this is an error in the Swift 6 language mode [DeclarationUnavailableFromAsynchronousContext] ```
This commit is contained in:
@@ -977,8 +977,8 @@ public:
|
||||
const_cast<ValueDecl *>(vd));
|
||||
// Emit a specific unavailable message when we know why a decl can't be
|
||||
// exposed, or a generic message otherwise.
|
||||
auto diagString = M.getASTContext().Diags.diagnosticStringFor(
|
||||
diag.getID(), PrintDiagnosticNamesMode::None);
|
||||
auto diagString =
|
||||
M.getASTContext().Diags.diagnosticStringFor(diag.getID());
|
||||
DiagnosticEngine::formatDiagnosticText(os, diagString, diag.getArgs(),
|
||||
DiagnosticFormatOptions());
|
||||
os << "\");\n";
|
||||
|
||||
Reference in New Issue
Block a user