@@ -3655,29 +3655,28 @@ enum class DeclTypeKind : unsigned {
3655
3655
static Type computeNominalType (NominalTypeDecl *decl, DeclTypeKind kind) {
3656
3656
ASTContext &ctx = decl->getASTContext ();
3657
3657
3658
- // Get the parent type.
3659
- Type Ty ;
3658
+ // If `decl` is a nested type, find the parent type.
3659
+ Type ParentTy ;
3660
3660
DeclContext *dc = decl->getDeclContext ();
3661
3661
if (!isa<ProtocolDecl>(decl) && dc->isTypeContext ()) {
3662
3662
switch (kind) {
3663
3663
case DeclTypeKind::DeclaredType: {
3664
- auto *nominal = dc->getSelfNominalTypeDecl ();
3665
- if (nominal)
3666
- Ty = nominal->getDeclaredType ();
3664
+ if (auto *nominal = dc->getSelfNominalTypeDecl ())
3665
+ ParentTy = nominal->getDeclaredType ();
3667
3666
break ;
3668
3667
}
3669
3668
case DeclTypeKind::DeclaredInterfaceType:
3670
- Ty = dc->getDeclaredInterfaceType ();
3671
- if (Ty ->is <ErrorType>())
3672
- Ty = Type ();
3669
+ ParentTy = dc->getDeclaredInterfaceType ();
3670
+ if (ParentTy ->is <ErrorType>())
3671
+ ParentTy = Type ();
3673
3672
break ;
3674
3673
}
3675
3674
}
3676
3675
3677
3676
if (!isa<ProtocolDecl>(decl) && decl->getGenericParams ()) {
3678
3677
switch (kind) {
3679
3678
case DeclTypeKind::DeclaredType:
3680
- return UnboundGenericType::get (decl, Ty , ctx);
3679
+ return UnboundGenericType::get (decl, ParentTy , ctx);
3681
3680
case DeclTypeKind::DeclaredInterfaceType: {
3682
3681
// Note that here, we need to be able to produce a type
3683
3682
// before the decl has been validated, so we rely on
@@ -3687,13 +3686,13 @@ static Type computeNominalType(NominalTypeDecl *decl, DeclTypeKind kind) {
3687
3686
for (auto param : decl->getGenericParams ()->getParams ())
3688
3687
args.push_back (param->getDeclaredInterfaceType ());
3689
3688
3690
- return BoundGenericType::get (decl, Ty , args);
3689
+ return BoundGenericType::get (decl, ParentTy , args);
3691
3690
}
3692
3691
}
3693
3692
3694
3693
llvm_unreachable (" Unhandled DeclTypeKind in switch." );
3695
3694
} else {
3696
- return NominalType::get (decl, Ty , ctx);
3695
+ return NominalType::get (decl, ParentTy , ctx);
3697
3696
}
3698
3697
}
3699
3698
0 commit comments