Skip to content

Commit e233f52

Browse files
committed
[Serialization] Make a warning the diagnostic about attempting recovery
Use the `attempting forced recovery` diagnostic as main warning to which we attach other messages as notes. Also mention the flag in the diagnostic to reinforce that the flag is active.
1 parent 642980c commit e233f52

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

include/swift/AST/DiagnosticsSema.def

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,9 +893,9 @@ NOTE(modularization_issue_side_effect_type_error,none,
893893
"could not deserialize type for %0",
894894
(DeclName))
895895

896-
NOTE(modularization_issue_worked_around,none,
897-
"attempting forced recovery using top-level declaration from %0",
898-
(Identifier))
896+
WARNING(modularization_issue_worked_around,none,
897+
"attempting forced recovery enabled by -experimental-force-workaround-broken-modules",
898+
())
899899

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

lib/Serialization/Deserialization.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,13 +1962,12 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) {
19621962
errorKind == ModularizationError::Kind::DeclMoved &&
19631963
!values.empty()) {
19641964
// Print the error as a remark and notify of the recovery attempt.
1965+
getContext().Diags.diagnose(getSourceLoc(),
1966+
diag::modularization_issue_worked_around);
19651967
llvm::handleAllErrors(std::move(error),
19661968
[&](const ModularizationError &modularError) {
1967-
modularError.diagnose(this, DiagnosticBehavior::Remark);
1969+
modularError.diagnose(this, DiagnosticBehavior::Note);
19681970
});
1969-
getContext().Diags.diagnose(getSourceLoc(),
1970-
diag::modularization_issue_worked_around,
1971-
foundIn);
19721971
} else {
19731972
return error;
19741973
}

test/Serialization/modularization-error.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
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: remark: 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: note: attempting forced recovery using top-level declaration from 'B'
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'
2323
// CHECK-WORKAROUND: func foo() -> some Proto
2424

2525
/// Change MyType into a function.

0 commit comments

Comments
 (0)