Skip to content

Commit 66402f1

Browse files
committed
Serialization: use diagnoseAndConsumeError in ModuleFile.cpp
1 parent 76533b8 commit 66402f1

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

lib/Serialization/ModuleFile.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ ModuleFile::loadNamedMembers(const IterableDeclContext *IDC, DeclBaseName N,
830830
} else {
831831
if (!getContext().LangOpts.EnableDeserializationRecovery)
832832
fatal(mem.takeError());
833-
consumeError(mem.takeError());
833+
diagnoseAndConsumeError(mem.takeError());
834834
}
835835
}
836836
}
@@ -860,7 +860,7 @@ void ModuleFile::lookupClassMember(ImportPath::Access accessPath,
860860
if (!declOrError) {
861861
if (!getContext().LangOpts.EnableDeserializationRecovery)
862862
fatal(declOrError.takeError());
863-
consumeError(declOrError.takeError());
863+
diagnoseAndConsumeError(declOrError.takeError());
864864
continue;
865865
}
866866

@@ -878,7 +878,7 @@ void ModuleFile::lookupClassMember(ImportPath::Access accessPath,
878878
if (!declOrError) {
879879
if (!getContext().LangOpts.EnableDeserializationRecovery)
880880
fatal(declOrError.takeError());
881-
consumeError(declOrError.takeError());
881+
diagnoseAndConsumeError(declOrError.takeError());
882882
continue;
883883
}
884884

@@ -902,7 +902,7 @@ void ModuleFile::lookupClassMember(ImportPath::Access accessPath,
902902
if (!declOrError) {
903903
if (!getContext().LangOpts.EnableDeserializationRecovery)
904904
fatal(declOrError.takeError());
905-
consumeError(declOrError.takeError());
905+
diagnoseAndConsumeError(declOrError.takeError());
906906
continue;
907907
}
908908

@@ -975,7 +975,7 @@ void ModuleFile::lookupObjCMethods(
975975
// Deserialize the method and add it to the list.
976976
auto declOrError = getDeclChecked(std::get<2>(result));
977977
if (!declOrError) {
978-
consumeError(declOrError.takeError());
978+
diagnoseAndConsumeError(declOrError.takeError());
979979
continue;
980980
}
981981

@@ -1002,13 +1002,16 @@ void ModuleFile::getTopLevelDecls(
10021002
if (declOrError.errorIsA<DeclAttributesDidNotMatch>()) {
10031003
// Decl rejected by matchAttributes, ignore it.
10041004
assert(matchAttributes);
1005-
consumeError(declOrError.takeError());
1005+
1006+
// We don't diagnose DeclAttributesDidNotMatch at the moment but
1007+
// let's use the diagnose consume variant for consistency.
1008+
diagnoseAndConsumeError(declOrError.takeError());
10061009
continue;
10071010
}
10081011

10091012
if (!getContext().LangOpts.EnableDeserializationRecovery)
10101013
fatal(declOrError.takeError());
1011-
consumeError(declOrError.takeError());
1014+
diagnoseAndConsumeError(declOrError.takeError());
10121015
continue;
10131016
}
10141017
if (!ABIRoleInfo(declOrError.get()).providesAPI()) // FIXME: flags
@@ -1024,7 +1027,7 @@ void ModuleFile::getExportedPrespecializations(
10241027
if (!declOrError) {
10251028
if (!getContext().LangOpts.EnableDeserializationRecovery)
10261029
fatal(declOrError.takeError());
1027-
consumeError(declOrError.takeError());
1030+
diagnoseAndConsumeError(declOrError.takeError());
10281031
continue;
10291032
}
10301033
results.push_back(declOrError.get());

test/Serialization/Recovery/module-recovery-remarks.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
// CHECK-MOVED: note: could not deserialize type for 'foo()'
3737
// CHECK-MOVED: error: cannot find 'foo' in scope
3838

39+
// CHECK-MOVED: remark: reference to type 'BrokenType' broken by a context change; 'BrokenType' was expected to be in 'A'
40+
// CHECK-MOVED: note: could not deserialize type for 'init(t:)'
41+
42+
// CHECK-MOVED: remark: reference to type 'BrokenType' broken by a context change; 'BrokenType' was expected to be in 'A'
43+
// CHECK-MOVED: note: could not deserialize type for 'member()'
44+
3945
/// Move A to the SDK, triggering a different note about layering.
4046
// RUN: mv %t/A.swiftmodule %t/sdk/A.swiftmodule
4147
// RUN: not %target-swift-frontend -c -O %t/Client.swift -I %t -I %t/sdk -Rmodule-recovery -sdk %t/sdk 2>&1 \
@@ -80,7 +86,18 @@ public func foo() -> BrokenType {
8086
fatalError()
8187
}
8288

89+
public class StableType {
90+
public init() {}
91+
public convenience init(t: BrokenType) { self.init() }
92+
public func member() -> BrokenType { fatalError() }
93+
}
94+
8395
//--- Client.swift
8496
import LibWithXRef
8597

8698
foo()
99+
100+
let s = StableType()
101+
s.member()
102+
103+
let s2 = StableType(42)

0 commit comments

Comments
 (0)