[NFC] Introduce TypeRepr::isSimpleUnqualifiedIdentifier to simplify some code

This commit is contained in:
Anthony Latsis
2023-12-05 12:58:10 +03:00
parent d6fd424560
commit fd4094cf09
9 changed files with 58 additions and 62 deletions

View File

@@ -4990,14 +4990,13 @@ void PrintAST::visitFuncDecl(FuncDecl *decl) {
}
}
if (!ResultTyLoc.getTypeRepr())
ResultTyLoc = TypeLoc::withoutLoc(ResultTy);
// FIXME: Hacky way to workaround the fact that 'Self' as return
// TypeRepr is not getting 'typechecked'. See
// \c resolveTopLevelIdentTypeComponent function in TypeCheckType.cpp.
if (auto *simId = dyn_cast_or_null<SimpleIdentTypeRepr>(ResultTyLoc.getTypeRepr())) {
if (simId->getNameRef().isSimpleName(Ctx.Id_Self))
ResultTyLoc = TypeLoc::withoutLoc(ResultTy);
if (ResultTyLoc.getTypeRepr() &&
ResultTyLoc.getTypeRepr()->isSimpleUnqualifiedIdentifier(
Ctx.Id_Self)) {
ResultTyLoc = TypeLoc::withoutLoc(ResultTy);
}
Printer << " -> ";