Skip to content

Commit 8e282c9

Browse files
committed
[Diagnostics] For errors that are downgraded to warnings via
warnUntilSwiftVersion, specify when the diagnostic will become an error in the message.
1 parent a06c4af commit 8e282c9

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

include/swift/AST/DiagnosticsCommon.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ NOTE(previous_decldef,none,
4444
NOTE(brace_stmt_suggest_do,none,
4545
"did you mean to use a 'do' statement?", ())
4646

47+
WARNING(error_in_future_swift_version,none,
48+
"%0; this is an error in Swift %1",
49+
(DiagnosticInfo *, unsigned))
50+
4751
// Generic disambiguation
4852
NOTE(while_parsing_as_left_angle_bracket,none,
4953
"while parsing this '<' as a type parameter bracket", ())

lib/AST/DiagnosticEngine.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//===----------------------------------------------------------------------===//
1717

1818
#include "swift/AST/DiagnosticEngine.h"
19+
#include "swift/AST/DiagnosticsCommon.h"
1920
#include "swift/AST/ASTContext.h"
2021
#include "swift/AST/ASTPrinter.h"
2122
#include "swift/AST/Decl.h"
@@ -321,8 +322,10 @@ InFlightDiagnostic::limitBehavior(DiagnosticBehavior limit) {
321322

322323
InFlightDiagnostic &
323324
InFlightDiagnostic::warnUntilSwiftVersion(unsigned majorVersion) {
324-
if (!Engine->languageVersion.isVersionAtLeast(majorVersion))
325-
this->limitBehavior(DiagnosticBehavior::Warning);
325+
if (!Engine->languageVersion.isVersionAtLeast(majorVersion)) {
326+
limitBehavior(DiagnosticBehavior::Warning)
327+
.wrapIn(diag::error_in_future_swift_version, majorVersion);
328+
}
326329

327330
return *this;
328331
}

0 commit comments

Comments
 (0)