AST: Make SubstFlags::UseErrorType the default behavior

We've fixed a number of bugs recently where callers did not expect
to get a null Type out of subst(). This occurs particularly often
in SourceKit, where the input AST is often invalid and the types
resulting from substitution are mostly used for display.

Let's fix all these potential problems in one fell swoop by changing
subst() to always return a Type, possibly one containing ErrorTypes.

Only a couple of places depended on the old behavior, and they were
easy enough to change from checking for a null Type to checking if
the result responds with true to hasError().

Also while we're at it, simplify a few call sites of subst().
This commit is contained in:
Slava Pestov
2019-08-22 01:04:59 -04:00
parent 1857a37e3b
commit 2dbeeb0d3f
36 changed files with 144 additions and 207 deletions

View File

@@ -873,9 +873,7 @@ void SwiftLangSupport::printMemberDeclDescription(const swift::ValueDecl *VD,
if (usePlaceholder)
OS << "<#T##";
if (auto substitutedTy = paramTy.subst(substMap))
paramTy = substitutedTy;
paramTy = paramTy.subst(substMap);
if (paramTy->hasError() && param->getTypeLoc().hasLocation()) {
// Fallback to 'TypeRepr' printing.
param->getTypeLoc().getTypeRepr()->print(OS);