Skip to content

Commit c5c850c

Browse files
committed
[Serialization] Try to improve readability of a common deserialization failures
Previous output: ``` could not deserialize type for ‘foo(_:)': top-level value not found Cross-reference to module ‘Bar_Private' ... Baz ``` New output: ``` Could not deserialize type for ‘foo(_:)' Caused by: top-level value not found Cross-reference to ‘Baz' in module 'Bar_Private' ```
1 parent caad212 commit c5c850c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/Serialization/DeserializationErrors.h

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -222,12 +222,11 @@ class XRefTracePath {
222222
}
223223

224224
void print(raw_ostream &os, StringRef leading = "") const {
225-
os << "Cross-reference to module '" << baseM.getName() << "'\n";
226-
for (auto &piece : path) {
227-
os << leading << "... ";
228-
piece.print(os);
229-
os << "\n";
230-
}
225+
os << "Cross-reference to '";
226+
interleave(path,
227+
[&](auto &piece) { piece.print(os); },
228+
[&] { os << '.'; });
229+
os << "' in module '" << baseM.getName() << "'\n";
231230
}
232231
};
233232

@@ -369,9 +368,9 @@ class TypeError : public llvm::ErrorInfo<TypeError, DeclDeserializationError> {
369368
}
370369

371370
void log(raw_ostream &OS) const override {
372-
OS << "could not deserialize type for '" << name << "'";
371+
OS << "Could not deserialize type for '" << name << "'";
373372
if (underlyingReason) {
374-
OS << ": ";
373+
OS << "\nCaused by: ";
375374
underlyingReason->log(OS);
376375
}
377376
}

0 commit comments

Comments
 (0)