Skip to content

Commit 0b6f61f

Browse files
committed
[Serialization] Invert order of diagnostics in forced recovery mode
1 parent 66c1a84 commit 0b6f61f

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -927,9 +927,9 @@ NOTE(modularization_issue_side_effect_type_error,none,
927927
"could not deserialize type for %0",
928928
(DeclName))
929929

930-
WARNING(modularization_issue_worked_around,none,
931-
"attempting forced recovery enabled by -experimental-force-workaround-broken-modules",
932-
())
930+
NOTE(modularization_issue_worked_around,none,
931+
"attempting forced recovery enabled by -experimental-force-workaround-broken-modules",
932+
())
933933

934934
ERROR(reserved_member_name,none,
935935
"type member must not be named %0, since it would conflict with the"

lib/Serialization/Deserialization.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2147,13 +2147,13 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) {
21472147
if (getContext().LangOpts.ForceWorkaroundBrokenModules &&
21482148
errorKind == ModularizationError::Kind::DeclMoved &&
21492149
!values.empty()) {
2150-
// Print the error as a remark and notify of the recovery attempt.
2151-
getContext().Diags.diagnose(getSourceLoc(),
2152-
diag::modularization_issue_worked_around);
2150+
// Print the error as a warning and notify of the recovery attempt.
21532151
llvm::handleAllErrors(std::move(error),
21542152
[&](const ModularizationError &modularError) {
2155-
modularError.diagnose(this, DiagnosticBehavior::Note);
2153+
modularError.diagnose(this, DiagnosticBehavior::Warning);
21562154
});
2155+
getContext().Diags.diagnose(getSourceLoc(),
2156+
diag::modularization_issue_worked_around);
21572157
} else {
21582158
return std::move(error);
21592159
}

test/Serialization/modularization-error.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,18 @@
1818
// RUN: %target-swift-frontend -emit-sil %t/LibWithXRef.swiftmodule -module-name LibWithXRef -I %t \
1919
// RUN: -experimental-force-workaround-broken-modules 2>&1 \
2020
// RUN: | %FileCheck --check-prefixes CHECK-WORKAROUND %s
21-
// CHECK-WORKAROUND: warning: attempting forced recovery enabled by -experimental-force-workaround-broken-modules
22-
// CHECK-WORKAROUND: note: reference to type 'MyType' broken by a context change; 'MyType' was expected to be in 'A', but now a candidate is found only in 'B'
21+
// CHECK-WORKAROUND: warning: reference to type 'MyType' broken by a context change; 'MyType' was expected to be in 'A', but now a candidate is found only in 'B'
22+
// CHECK-WORKAROUND: A.MyType
23+
// CHECK-WORKAROUND: ^
24+
// CHECK-WORKAROUND: A.swiftmodule:1:1: note: declaration was expected to be found in this module
25+
// CHECK-WORKAROUND: <binary format>
26+
// CHECK-WORKAROUND: ^
27+
// CHECK-WORKAROUND: B.swiftmodule:1:1: note: declaration was found in this module
28+
// CHECK-WORKAROUND: <binary format>
29+
// CHECK-WORKAROUND: ^
30+
// CHECK-WORKAROUND: LibWithXRef.swiftmodule:1:1: note: attempting forced recovery enabled by -experimental-force-workaround-broken-modules
31+
// CHECK-WORKAROUND: <binary format>
32+
// CHECK-WORKAROUND: ^
2333
// CHECK-WORKAROUND: func foo() -> some Proto
2434

2535
/// Change MyType into a function.

0 commit comments

Comments
 (0)