@@ -3877,11 +3877,20 @@ class TypeReprAvailabilityWalker : public ASTWalker {
3877
3877
const ExportContext &where;
3878
3878
DeclAvailabilityFlags flags;
3879
3879
3880
- bool checkIdentTypeRepr (IdentTypeRepr *ITR) {
3880
+ bool checkDeclRefTypeRepr (DeclRefTypeRepr *declRefTR) const {
3881
3881
ArrayRef<AssociatedTypeDecl *> primaryAssociatedTypes;
3882
3882
3883
- if (auto *typeDecl = ITR->getBoundDecl ()) {
3884
- auto range = ITR->getNameLoc ().getSourceRange ();
3883
+ if (auto *memberTR = dyn_cast<MemberTypeRepr>(declRefTR)) {
3884
+ // If the base is unavailable, don't go on to diagnose
3885
+ // the member since that will just produce a redundant
3886
+ // diagnostic.
3887
+ if (diagnoseTypeReprAvailability (memberTR->getBase (), where, flags)) {
3888
+ return true ;
3889
+ }
3890
+ }
3891
+
3892
+ if (auto *typeDecl = declRefTR->getBoundDecl ()) {
3893
+ auto range = declRefTR->getNameLoc ().getSourceRange ();
3885
3894
if (diagnoseDeclAvailability (typeDecl, range, nullptr , where, flags))
3886
3895
return true ;
3887
3896
@@ -3892,7 +3901,7 @@ class TypeReprAvailabilityWalker : public ASTWalker {
3892
3901
3893
3902
bool foundAnyIssues = false ;
3894
3903
3895
- if (auto *GTR = dyn_cast<GenericIdentTypeRepr>(ITR )) {
3904
+ if (auto *GTR = dyn_cast<GenericIdentTypeRepr>(declRefTR )) {
3896
3905
auto genericFlags = flags;
3897
3906
genericFlags -= DeclAvailabilityFlag::AllowPotentiallyUnavailableProtocol;
3898
3907
@@ -3932,27 +3941,8 @@ class TypeReprAvailabilityWalker : public ASTWalker {
3932
3941
if (!declRefTR)
3933
3942
return Action::Continue ();
3934
3943
3935
- auto *rootComp = declRefTR->getRoot ();
3936
- if (auto *identBase = dyn_cast<IdentTypeRepr>(rootComp)) {
3937
- if (checkIdentTypeRepr (identBase)) {
3938
- foundAnyIssues = true ;
3939
- return Action::SkipNode ();
3940
- }
3941
- } else if (diagnoseTypeReprAvailability (rootComp, where, flags)) {
3944
+ if (checkDeclRefTypeRepr (declRefTR)) {
3942
3945
foundAnyIssues = true ;
3943
- return Action::SkipNode ();
3944
- }
3945
-
3946
- if (auto *memberTR = dyn_cast<MemberTypeRepr>(T)) {
3947
- for (auto *comp : memberTR->getMemberComponents ()) {
3948
- // If a parent type is unavailable, don't go on to diagnose
3949
- // the member since that will just produce a redundant
3950
- // diagnostic.
3951
- if (checkIdentTypeRepr (comp)) {
3952
- foundAnyIssues = true ;
3953
- break ;
3954
- }
3955
- }
3956
3946
}
3957
3947
3958
3948
// We've already visited all the children above, so we don't
0 commit comments