mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user