From 5873b043239bd20b8fe3e6424a4647115819ad77 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Thu, 12 Mar 2020 21:03:04 +0100 Subject: [PATCH] Renamed a variable to be more descriptive in computeNominalType() --- lib/AST/Decl.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index f79ef285d2093..1e77b96aa3737 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -3655,21 +3655,20 @@ enum class DeclTypeKind : unsigned { static Type computeNominalType(NominalTypeDecl *decl, DeclTypeKind kind) { ASTContext &ctx = decl->getASTContext(); - // Get the parent type. - Type Ty; + // If `decl` is a nested type, find the parent type. + Type ParentTy; DeclContext *dc = decl->getDeclContext(); if (!isa(decl) && dc->isTypeContext()) { switch (kind) { case DeclTypeKind::DeclaredType: { - auto *nominal = dc->getSelfNominalTypeDecl(); - if (nominal) - Ty = nominal->getDeclaredType(); + if (auto *nominal = dc->getSelfNominalTypeDecl()) + ParentTy = nominal->getDeclaredType(); break; } case DeclTypeKind::DeclaredInterfaceType: - Ty = dc->getDeclaredInterfaceType(); - if (Ty->is()) - Ty = Type(); + ParentTy = dc->getDeclaredInterfaceType(); + if (ParentTy->is()) + ParentTy = Type(); break; } } @@ -3677,7 +3676,7 @@ static Type computeNominalType(NominalTypeDecl *decl, DeclTypeKind kind) { if (!isa(decl) && decl->getGenericParams()) { switch (kind) { case DeclTypeKind::DeclaredType: - return UnboundGenericType::get(decl, Ty, ctx); + return UnboundGenericType::get(decl, ParentTy, ctx); case DeclTypeKind::DeclaredInterfaceType: { // Note that here, we need to be able to produce a type // before the decl has been validated, so we rely on @@ -3687,13 +3686,13 @@ static Type computeNominalType(NominalTypeDecl *decl, DeclTypeKind kind) { for (auto param : decl->getGenericParams()->getParams()) args.push_back(param->getDeclaredInterfaceType()); - return BoundGenericType::get(decl, Ty, args); + return BoundGenericType::get(decl, ParentTy, args); } } llvm_unreachable("Unhandled DeclTypeKind in switch."); } else { - return NominalType::get(decl, Ty, ctx); + return NominalType::get(decl, ParentTy, ctx); } }