Skip to content

Commit 83e9a7d

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

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

lib/Serialization/ModuleFile.cpp

Lines changed: 8 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,13 @@ void ModuleFile::getTopLevelDecls(
10021002
if (declOrError.errorIsA<DeclAttributesDidNotMatch>()) {
10031003
// Decl rejected by matchAttributes, ignore it.
10041004
assert(matchAttributes);
1005-
consumeError(declOrError.takeError());
1005+
diagnoseAndConsumeError(declOrError.takeError());
10061006
continue;
10071007
}
10081008

10091009
if (!getContext().LangOpts.EnableDeserializationRecovery)
10101010
fatal(declOrError.takeError());
1011-
consumeError(declOrError.takeError());
1011+
diagnoseAndConsumeError(declOrError.takeError());
10121012
continue;
10131013
}
10141014
if (!ABIRoleInfo(declOrError.get()).providesAPI()) // FIXME: flags
@@ -1024,7 +1024,7 @@ void ModuleFile::getExportedPrespecializations(
10241024
if (!declOrError) {
10251025
if (!getContext().LangOpts.EnableDeserializationRecovery)
10261026
fatal(declOrError.takeError());
1027-
consumeError(declOrError.takeError());
1027+
diagnoseAndConsumeError(declOrError.takeError());
10281028
continue;
10291029
}
10301030
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)